Cod sursa(job #314404)
Utilizator | Data | 11 mai 2009 19:24:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include<stdio.h>
#define mod 1999999973;
long long a,b,x,p;
int main(){
FILE*f=fopen("lgput.in","r");
FILE*g=fopen("lgput.out","w");
fscanf(f,"%lld %lld",&a,&b);
p=1;
x=a;
while(b){
if(b%2==1)
p=(p*x)%mod;
x=(x*x)%mod;
b/=2;
}
fprintf(g,"%lld",p);
fclose(f);
fclose(g);
return 0;
}