Cod sursa(job #2571629)
Utilizator | Data | 5 martie 2020 09:01:32 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const long long mod = 1999999973;
long long n, p, aux = 1;
int main()
{
fin >> n >> p;
while (p != 1)
{
if (p % 2)
{
aux *= n;
aux %= mod;
}
n *= n;
n %= mod;
p /= 2;
}
fout << (n * aux) % mod;
fin.close();
fout.close();
return 0;
}