Pagini recente » Diferente pentru monthly-2014/runda-1/solutii intre reviziile 10 si 15 | Rating Mark Neagu (mark.neagu) | Istoria paginii utilizator/futuristul | Cod sursa (job #322969) | Cod sursa (job #2247757)
#include <iostream>
#include <fstream>
using namespace std;
unsigned long long n,p,x;
unsigned long long put (int a,int b)
{
if(b==0)
return 1;
else
if(b==1)
return a;
if(b%2==0)
x=put(a%1999999973*a%1999999973,b/2)%1999999973;
else
x=a%1999999973*put(a%1999999973*a%1999999973,(b-1)/2)%1999999973;
return x;
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>n>>p;
fout<<put(n,p);
}