Cod sursa(job #1889452)
Utilizator | Data | 22 februarie 2017 18:46:18 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <cstdio>
using namespace std;
const int mod = 1999999973;
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
long long n,p,r = 1;
scanf("%lld %lld", &n, &p);
while(p)
{
if(p % 2)
{
r *= n;
r %= mod;
}
n *= n;
n %= mod;
p /= 2;
}
printf("%lld\n", r);
return 0;
}