Cod sursa(job #1956099)
Utilizator | Data | 6 aprilie 2017 14:51:50 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <iostream>
#include <fstream>
using namespace std;
int n,p,x,mod=1999999973;
int main()
{freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d%d", &n, &p);
x=1;
while(p)
{if(p%2)
x=x*n%mod;
n=n*n%mod;
p=p/2;
}
printf("%d", x);
return 0;
}