Cod sursa(job #2794726)
| Utilizator | Data | 5 noiembrie 2021 12:42:37 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
#define MOD 1999999973
using namespace std;
using ll = long long;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int restPow(ll a, int n)
{
ll result = 1;
while (n) {
if (n & 1) result = (result * a) % MOD;
a = (a * a) % MOD;
n >>= 1;
}
return result;
}
int main()
{
int x, y;
fin >> x >> y;
fout << restPow(x, y);
fin.close();
fout.close();
return 0;
}
