Pagini recente » Cod sursa (job #1144175) | Cod sursa (job #2237866) | Cod sursa (job #188521) | Cod sursa (job #1344746) | Cod sursa (job #1524894)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int mod = 1999999973;
int lgput(int n, int p) {
if(p == 1)
return n % mod;
if(p % 2 == 0) {
int x = lgput(n, p / 2); // calculam n ^ (p/2)
return (1LL * x * x) % mod;
}
else {
int x = lgput(n, p / 2);
return (1LL * x * x * n) % mod;
}
}
int main()
{
int n, p;
in >> n >> p;
out << lgput(n, p);
return 0;
}