Cod sursa(job #676673)
| Utilizator | Data | 9 februarie 2012 15:08:35 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | c | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#define mod 1999999973
#include<stdio.h>
long long int putere(long long int a, long long int b)
{
long long int rezultat=1;
while(b)
{
if(b%2)
rezultat=(a*a)%mod;
a=rezultat;
b\=2;
}
return rezultat;
}
int main()
{
FILE *f=fopen("lgput.in","r"),*g=fopen("lgput.out","w");
long long int a,b;
fscanf(f,"%dll %dll", &a, &b);
fprintf(g,"%dll", putere(a,b));
fclose(f);
fclose(g);
return 0;
}