Cod sursa(job #729801)
Utilizator | Data | 30 martie 2012 09:57:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <cstdio>
using namespace std;
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
unsigned long long b, exp, p=1;
scanf("%lld%lld", &b, &exp);
while (exp > 1)
{
if (!(exp%2))
{
b = b * b;
exp /= 2;
}
else
{
exp--;
p *= b;
}
}
p *= b;
printf("%lld\n", p%1999999973);
return 0;
}