Pagini recente » Diferente pentru problema/emm intre reviziile 3 si 4 | Atasamentele paginii Profil spike_eu | Cod sursa (job #1772983)
#include <iostream>
#include <fstream>
#define infile "lgput.in"
#define outfile "lgput.out"
#define mod 1999999973
using namespace std;
ifstream in(infile);
ofstream out(outfile);
int x, p;
int putere(int x, int p)
{
if(p == 0) return 1;
if(p == 1) return x%mod;
if(p%2 == 0) return putere(x*x, p/2)%mod;
if(p%2 == 1) return (x*putere(x*x, (p-1)/2))%mod;
}
int main()
{
in >> x >> p;
out << putere(x, p) << '\n';
return 0;
}