Cod sursa(job #2869644)
Utilizator | Data | 11 martie 2022 18:37:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long LogP(long long a, long long b)
{
int p = 1;
while (b > 0)
{
if (b % 2 == 1) p = 1LL * p * a % MOD;
a = 1LL * a * a % MOD;
b /= 2;
}
return p;
}
int main()
{
long long a, b;
fin >> a >> b;
fout << LogP(a, b);
return 0;
}