Cod sursa(job #2568644)
Utilizator | Data | 4 martie 2020 08:57:29 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | r3capitusulare | Marime | 0.3 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
using i64 = long long;
const int mod = 1999999973;
main()
{
i64 n, p;
fin >> n >> p;
i64 ans = 1;
for(; p; p >>= 1, n = (n * n) % mod)
if(p & 1)
ans = (ans * n) % mod;
fout << ans << '\n';
}