Cod sursa(job #2868313)
Utilizator | Data | 10 martie 2022 21:00:37 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
#define P 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, x;
void LogP(long long a, long long n)
{
long long p = 1;
while(n != 0)
{
if(n % 2 == 1)
p = p * 1LL * p * a % P;
n = n / 2;
a = 1LL * a * a % P;
}
fout << p << "\n";
}
int main()
{
fin >> x >> n;
LogP(x, n);
fout.close();
return 0;
}