Cod sursa(job #1046153)
Utilizator | Data | 2 decembrie 2013 18:27:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <stdio.h>
int expo(int a,int b,int mod) {
int ret = 1;
for (;b;b >>= 1) {
if (b & 1) {
ret = 1LL * a * a % mod;
}
a = 1LL * a * a % mod;
}
return ret;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
int n, p;
scanf("%d %d",&n,&p);
printf("%d\n",expo(n,p,1999999973));
return 0;
}