Pagini recente » Cod sursa (job #1058339) | Cod sursa (job #1497133) | Cod sursa (job #2171851) | Cod sursa (job #2951006) | Cod sursa (job #2127302)
#include <fstream>
#define mod1 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long RidicareLaPutere(int N, long long x) {
long long sol = 1;
while (N) {
if (N & 1) { //daca N e impar
N--;
sol *= x;
}
else {
x *= x;
x %= mod1;
N >>= 1; //N = N / 2
}
sol %= mod1;
}
return sol;
}
inline void Read() {
int N; long long x;
fin >> x >> N; //x - baza, N - puterea
fout << RidicareLaPutere(N, x);
}
int main () {
Read();
fin.close(); fout.close(); return 0;
}