Cod sursa(job #3233409)
Utilizator | Data | 3 iunie 2024 12:03:40 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include<bits/stdc++.h>
#define ll long long
std::ifstream fin("lgput.in");
std::ofstream fout("lgput.out");
const ll MOD = 1999999973;
ll n, p;
ll fastexp(ll a, ll b){
if(b == 0)
return 1;
ll res = fastexp(a, b / 2);
res = (res * res) % MOD;
if(b & 1)
res = (res * a) % MOD;
return res;
}
int main(){
fin >> n >> p;
fout << fastexp(n, p);
}