Cod sursa(job #2864238)
Utilizator | Data | 7 martie 2022 18:29:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n, p;
const int mod = 1999999973;
int LgPow(int a, int n)
{
int p = 1;
while(n)
{
if(n % 2 == 1)
p = (1ll * p * a) % mod;
a = (1ll * a * a) % mod;
n /= 2;
}
return p;
}
int main()
{
fin >> n >> p;
fout << LgPow(n, p);
return 0;
}