Cod sursa(job #2642131)
Utilizator | Data | 13 august 2020 19:12:32 | |
---|---|---|---|
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>
#define ll long long
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main() {
ll n, p;
ll ans = 1;
fin >> n >> p;
for(int i = 0; (1 << i) <= p; i++) {
if((1 << i) & p)
ans = ans * n % MOD;
n = n * n % MOD;
}
fout << ans;
}