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