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