Pagini recente » Cod sursa (job #210268) | Cod sursa (job #941386) | Cod sursa (job #59898) | Cod sursa (job #2249939) | Cod sursa (job #1524898)
#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 == 0)
return 1;
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 * ((1LL * x * x) % mod) * n) % mod;
}
}
int main()
{
int n, p;
in >> n >> p;
n = n % mod;
out << lgput(n, p);
return 0;
}