Cod sursa(job #2808224)
| Utilizator | Data | 24 noiembrie 2021 19:00:25 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll N, P; fin >> N >> P;
ll r = 1, m = 1999999973;
while (P > 0) {
if (P % 2)
r = (r*N)%m;
N = (N*N)%m;
P /= 2;
}
fout << r;
return 0;
}
