Cod sursa(job #1453201)
| Utilizator | Data | 22 iunie 2015 22:43:31 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
long long mod = 1999999973, n, p;
cin >> n >> p;
long ans = 1;
n %= mod;
while (p > 0) {
if (p % 2 == 1) {
ans = (ans * n) % mod;
}
p >>= 1;
n = (n * n) % mod;
}
cout << ans;
return 0;
}
