Cod sursa(job #2814359)
Utilizator | Data | 7 decembrie 2021 23:06:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int main() {
unsigned n, p;
fin >> n >> p;
int ans = 1;
while(p) {
if(p & 1)
ans = (1LL * ans * n) % MOD;
n = (1LL * n * n) % MOD;
p >>= 1;
}
fout << ans;
fin.close();
fout.close();
return 0;
}