Cod sursa(job #2574839)
| Utilizator | Data | 6 martie 2020 10:16:05 | |
|---|---|---|---|
| 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
#define ull unsigned long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ull LogPow(ull x, ull n)
{
if (n == 0) return 1;
else if (n % 2 == 0) return LogPow(x * x % MOD, n / 2);
else return x * LogPow(x * x % MOD, n / 2) % MOD;
}
ull x, n;
int main()
{
fin >> x >> n;
fout << LogPow(x, n);
return 0;
}
