Cod sursa(job #2641659)
Utilizator | Data | 12 august 2020 11:43:38 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
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() {
int n, p;
ll ans = 1;
fin >> n >> p;
for(int i = 1; i <= 32; i++) {
if((1 << (i - 1)) & p)
ans = ans * n % MOD;
n = n * n % MOD;
}
fout << ans;
}