Pagini recente » Cod sursa (job #3187447) | Cod sursa (job #256038) | Cod sursa (job #1316463) | Cod sursa (job #1541627) | Cod sursa (job #1001125)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int weird = 1999999973;
int powLog(int n, int p);
int main()
{
int n,p;
fin>>n;
fin>>p;
fout << powLog(n,p)% weird;
return 0;
}
int powLog(int n, int p)
{
if(p==0) return 1;
else if(p==1) return n % weird;
else if(p%2==0) return powLog(n*n,p/2) % weird;
else return n*powLog(n*n,(p-1)/2) % weird;
}