Cod sursa(job #670366)
Utilizator | Data | 28 ianuarie 2012 21:50:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.27 kb |
#include<stdio.h>
long long a,b,p=1;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&a,&b);
while (b)
if (b%2) {b--;p=((long long)p*a)%1999999973;}
else {b/=2;a=((long long)a*a)%1999999973;}
printf("%d\n",p);
}