Cod sursa(job #2931636)
Utilizator | Data | 31 octombrie 2022 17:43:51 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <bits/stdc++.h>
using namespace std;
#define MOD 1999999973
uint pow(uint n, uint p) {
uint ans = 1;
while (p) {
if (p & 1)
ans = (1LL * ans * n) % MOD;
n = (1LL * n * n) % MOD;
p >>= 1;
}
return ans;
}
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
uint n, p;
fin >> n >> p;
fout << pow(n, p);
}