Pagini recente » Cod sursa (job #2326770) | Cod sursa (job #1739051) | Cod sursa (job #1803659) | Cod sursa (job #2563171) | Cod sursa (job #983388)
Cod sursa(job #983388)
#include <fstream>
unsigned long int N, P;
using namespace std;
unsigned long int exp(unsigned long int N, unsigned long int P)
{
if(P==0) return 1;
else if(P==1) return N;
else if(P%2==0) return exp(N*N, P/2);
else if(P%2!=0) return N*exp(N*N, (P-1)/2);
}
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f>>N>>P;
g<<exp(N, P)%1999999973;
g.close();
f.close();
}