Pagini recente » Istoria paginii runda/eusebiu_oji_2015_cls10 | Cod sursa (job #2074568) | Cod sursa (job #2841540) | Profil BarsanEmilianIoan | Cod sursa (job #1301751)
#include<vector>
#include<iostream>
#include<fstream>
#define max 1999999973
using namespace std;
int fast_power(int p, int q) {
int result = 1;
while(q > 0) {
if(q % 2){
result = ((result % max) *(p % max)) % max;
q--;
}
p = (((p % max)*(p % max)) % max);
q = q >> 1;
}
return result;
}
int main(){
int n, p;
ifstream in; in.open("lgput.in");
ofstream out; out.open("lgput.out");
in >> n; in >> p;
cout << n << " " << p << endl;
out << fast_power(n,p);
out.close();
in.close();
return 0;
}