Cod sursa(job #1456256)
| Utilizator | Data | 30 iunie 2015 11:09:25 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <cstdio>
#include <algorithm>
#include <cstring>
#define mod 1999999973
using namespace std;
long long n, p, sol;
int main()
{
int i;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld %lld", &n, &p);
sol = 1LL;
for (i = 0; 1 << i <= p; ++ i)
{
if (p & (1 << i))
sol = (sol * n * 1LL) % mod;
n = (n * n) % mod;
}
printf("%lld", sol);
return 0;
}
