Cod sursa(job #1825727)
| Utilizator | Data | 9 decembrie 2016 16:41:27 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
const int mod = 1999999973;
int main() {
ios_base :: sync_with_stdio (false);
long long n, p, ans = 1;
fin >> n >> p;
while (p) {
if (p & 1) {
ans = (ans * n) % mod;
}
n = (n * n) % mod;
p = p >> 1;
}
fout << ans << "\n";
fin.close();
fout.close();
return 0;
}
