Cod sursa(job #949069)
Utilizator | Data | 12 mai 2013 13:49:43 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <cstdio>
using namespace std;
FILE *f=fopen ("lgput.in","r");
FILE *g=fopen ("lgput.out","w");
int main(){
int n,x,p=1;
fscanf (f,"%d%d",&n,&x);
while (x>0){
if (x%2==1){
p=p*n%1999999973;
x--;
}
n=n*n%1999999973;
x=x/2;
}
fprintf (g,"%d",p);
return 0;
}