Cod sursa(job #1880995)
Utilizator | Data | 16 februarie 2017 08:37:32 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <stdio.h>
using namespace std;
FILE *f,*g;
int main()
{
long long n,p,x=1999999973,rez=1;
f=fopen("lgput.in","r");
g=fopen("lgput.in","w");
fscanf(f,"%lld %lld",&n,&p);
while(p>0)
{
if(p%2==0)
{
rez=rez*n%x;
p--;
}
n*=n;
p/=2;
}
fprintf(g,"%lld",rez);
fclose(f);
fclose(g);
return 0;
}