Cod sursa(job #1494967)
Utilizator | Data | 2 octombrie 2015 09:12:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <cstdio>
using namespace std;
const int mod = 1999999973;
int n,p;
int main(){
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d %d", &n, &p);
int r = 1;
while(p > 1){
if(p % 2){
r *= n;
r %= mod;
}
n *= n;
n %= mod;
p /= 2;
}
n *= r;
n %= mod;
printf("%d\n", n);
return 0;
}