Pagini recente » Cod sursa (job #2259500) | Cod sursa (job #1775105) | Cod sursa (job #1722727) | Cod sursa (job #2255820) | Cod sursa (job #2223419)
#include <stdio.h>
#include <stdlib.h>
#define IMPART 1999999973
long long computePower(long long n,long long p){
if(p==1) return n;
else if(p%2==0) return (computePower((n*n)%IMPART,p/2))%IMPART;
else return (n*computePower((n*n)%IMPART,(p-1)/2))%IMPART;
}
int main()
{
FILE*fin,*fout;
fin = fopen("lgput.in" ,"r");
fout = fopen("lgput.out" ,"w");
long long n,p;
fscanf(fin, "%lld%lld" ,&n,&p);
fprintf(fout, "%lld\n" ,computePower(n,p));
fclose(fin);
fclose(fout);
return 0;
}