Pagini recente » Monitorul de evaluare | Borderou de evaluare (job #2961762) | clasament-arhiva-educationala | Cod sursa (job #2227620)
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int putere(long long a, long long b) {
if (b<0)
return putere(1/a,-b);
else if (b==0)
return 1;
else if (b==1)
return a;
else if (b%2==0)
return (putere(a*a, b/2))%1999999973;
else if (b%2==1)
return ((a%1999999973)*(putere(a*a, (b-1)/2))%1999999973)%1999999973;
}
long long n,p;
int main() {
fin>>n>>p;
fout<<putere(n,p);
return 0;
}