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