Cod sursa(job #2618707)
| Utilizator | Data | 25 mai 2020 19:58:01 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll mod = 1999999973;
ll power(ll base, ll pw) {
if (pw == 1)
return base;
if (pw == 0)
return 1;
if (pw % 2)
return base * power(base % mod * base % mod, pw / 2) % mod;
return power(base % mod * base % mod, pw / 2) % mod;
}
int main() {
ll k, n;
fin >> n >> k;
fout << power(n, k);
return 0;
}
