Pagini recente » Cod sursa (job #740041) | Cod sursa (job #2281618) | Cod sursa (job #2278874) | Cod sursa (job #1343912) | Cod sursa (job #1792162)
#include <iostream>
#include <fstream>
const int MOD = 1999999973;
int power(int x, int n){
if(n == 0){
return 1;
}
if(n == 1){
return x % MOD;
}
if(n % 2 == 0){
return power(x, n / 2) * power(x, n / 2) % MOD;
}
if(n % 2 == 1){
return x * power(x, (n - 1) / 2) * power(x, (n - 1) / 2) % MOD;
}
}
int main(){
std::ifstream fin("lgput.in");
std::ofstream fout("lgput.out");
int n, p;
fin >> n >> p;
fout << power(n, p);
fin.close();
fout.close();
return 0;
}