Pagini recente » Beri | Atasamentele paginii oni_2010 | Cod sursa (job #712939) | Cod sursa (job #1774591) | Cod sursa (job #1524897)
#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;
n = n % mod;
out << lgput(n, p);
return 0;
}