Cod sursa(job #1134796)
Utilizator | Data | 6 martie 2014 21:45:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <cstdio>
const int mod = 1999999973;
int main()
{
freopen("lgput.in","rt",stdin);
freopen("lgput.out","wt",stdout);
unsigned long long int a,b;
scanf("%llu%llu",&a,&b);
unsigned long long int c = 1;
while(b){
if(b%2){
c*=a;
c%=mod;
}
b/=2;
a*=a;
a%=mod;
}
printf("%llu",c);
}