Pagini recente » Cod sursa (job #1769148) | Cod sursa (job #1827630) | Cod sursa (job #2716441) | Cod sursa (job #1436375) | Cod sursa (job #2023804)
#include <fstream>
using namespace std;
int modPrime(long long n){
const int PRIME = 1999999973;
return n % PRIME;
}
long long product(int a, int b){
return 1LL * a * b;
}
int fastExp(int n, int exp, long long (*p)(int, int), int (*f)(long long)){
switch(exp){
case 0 : return 1;
default : return (exp % 2 == 0) ? fastExp(f(p(n, n)), exp >> 1, p, f) : f(p(n, fastExp(n, --exp, p, f)));
}
}
int main(){
ifstream cin("lgput.in");
ofstream cout("lgput.out");
int k, n;
cin >> n >> k;
cout << fastExp(n, k, product, modPrime);
cin.close();
cout.close();
return 0;
}