Cod sursa(job #2177583)
Utilizator | Data | 18 martie 2018 17:59:00 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int main() {
long long n, p, ans = 1;
fin >> n >> p;
while (p) {
if (p & 1) {
ans = (ans * n) % MOD;
}
n = (n * n) % MOD;
p >>= 1;
}
fout << ans << '\n';
fout.close();
return 0;
}