Cod sursa(job #1508290)
| Utilizator | Data | 22 octombrie 2015 14:32:54 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include<cstdio>
using namespace std;
#define MOD 1999999973
unsigned power(unsigned a,unsigned b){
int sol=1;
for(; b; b>>=1){
if(b&1){
sol=(sol*a)%MOD;
}
a=(a*a)%MOD;
}
return sol;
}
int main(){
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
unsigned n,p;
scanf("%d %d", &n, &p);
unsigned val=power(n,p);
printf("%d\n", val);
}
