Cod sursa(job #2868327)
Utilizator | Data | 10 martie 2022 21:05:08 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 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(int a, int n)
{
int p = 1;
while(n != 0)
{
if(n % 2 == 1)
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;
}