Cod sursa(job #1650465)
Utilizator | Data | 11 martie 2016 18:32:24 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <cstdio>
using namespace std;
const int mod = 1999999973;
long long n,p,ax;
int main(){
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld %lld", &n, &p);
ax = 1;
while(p){
if(p % 2){
ax *= n;
ax %= mod;
}
n *= n;
n %= mod;
p /= 2;
}
printf("%lld\n", ax);
return 0;
}