Pagini recente » Cod sursa (job #92618) | Cod sursa (job #2528332) | Cod sursa (job #1976650) | Cod sursa (job #2528881) | Cod sursa (job #1110463)
/// Craciun Catalin
/// Lgput
/// www.infoarena.ro/problema/lgput
#include <fstream>
#include <iostream>
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long a,p;
long long exponential(long long x, long long putere)
{
if (putere<0)
return exponential(1/x, -putere);
if (putere==0)
return 1;
if (putere==1)
return x;
if (putere%2==0)
return exponential((x*x)%mod,putere/2)%mod;
if (putere%2!=0)
return (x*exponential((x*x)%mod,(putere-1)/2))%mod;
return 0;
}
int main()
{
f>>a>>p;
f.close();
g<<exponential(a,p)%mod<<'\n';
g.close();
return 0;
}