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