Cod sursa(job #1508297)
| Utilizator | Data | 22 octombrie 2015 14:35:58 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include<cstdio>
using namespace std;
#define MOD 1999999973
unsigned power(unsigned long long 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);
}
