Pagini recente » Statistici Butucel Marian (marian.butucel) | Cod sursa (job #1875053) | Cod sursa (job #1229810) | Cod sursa (job #2395357) | Cod sursa (job #1001136)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int weird = 1999999973;
long long powLog(int n, int p);
int main()
{
int n,p;
fin>>n;
fin>>p;
fout << powLog(n,p)% weird;
return 0;
}
long long powLog(int n, int p)
{
if(p==0) return 1;
else if(p==1) return n % weird;
else if(p%2==0) return powLog(((long long)n*n )% weird,p/2)% weird;
else return ((long long)n*powLog(((long long)n*n)% weird,(p-1)/2))% weird;
}