Pagini recente » Cod sursa (job #1562673) | Cod sursa (job #535136) | Cod sursa (job #734836) | Cod sursa (job #849707) | Cod sursa (job #1524899)
#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;
}