Cod sursa(job #876720)
Utilizator | Data | 12 februarie 2013 00:55:28 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <cstdio>
using namespace std;
long long p=1,a,b;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&a,&b);
while(b!=0)
{
if(b%2!=0)
{
p=(p*a)%1999999973;
b--;
}
else
{
a=(a*a)%1999999973;
b/=2;
}
}
printf("%lld",p);
return 0;
}