Cod sursa(job #2568650)
Utilizator | Data | 4 martie 2020 08:59:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int Mod = 1999999973;
int n, x;
int Lgput(int a, int b)
{
int p = 1;
while(b)
{
if(b % 2) p = 1LL * p * a % Mod;
a = 1LL * a * a % Mod;
b /= 2;
}
return p;
}
int main()
{
fin >> n >> x;
fout << Lgput(n, x) << "\n";
fin.close();
fout.close();
return 0;
}