Cod sursa(job #2737447)
Utilizator | Data | 4 aprilie 2021 19:17:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long LgPow(int x, int p)
{
int answer = 1;
while(p)
{
if(p % 2 == 1)
answer = (answer * x) % mod;
x = (x * x) % mod;
p /= 2;
}
return answer;
}
int main()
{
int n, p;
fin >> n >> p;
fout << LgPow(n, p);
return 0;
}