Cod sursa(job #2641281)
Utilizator | Data | 10 august 2020 21:02:44 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <iostream>
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main() {
long long n, p, ans = 1;
fin >> n >> p;
while (p) {
if (p % 2 == 1)
ans = (ans * n) % MOD;
n *= n;
n %= MOD;
p /= 2;
}
fout << ans;
}