Pagini recente » Cod sursa (job #1869724) | Cod sursa (job #1608271) | Cod sursa (job #1846159) | Cod sursa (job #542640) | Cod sursa (job #1343591)
#include <fstream>
using namespace std;
ifstream fin("inversmodular.in");
ofstream fout("inversmodular.out");
long long rez=1,a,n;
void citire()
{
fin>>a>>n;
}
void putere(long long x,long long n,long long &rez)
{
while(n>0)
{
if(n%2==0)
{x=x*x;
n=n/2;
}
else
{
rez=rez*x;
x=x*x;
n=n/2;
}
}
}
int main()
{
citire();
putere(a,n-2,rez);
fout<<rez;
return 0;
}