Pagini recente » Diferente pentru problema/delay intre reviziile 1 si 8 | Atasamentele paginii Profil hanciuc_vasile | Cod sursa (job #2965353) | Cod sursa (job #907895) | Cod sursa (job #2855595)
#include <fstream>
using namespace std;
ifstream fin ("inversmodular.in");
ofstream fout("inversmodular.out");
int Pow(int x, int y, int mod)
{
if (y==0) return 1;
if (y==1) return x%mod;
int p=Pow(x, y/2, mod);
if (y%2==0) return (1LL*p*p)%mod;
else return ((1LL*p*p)%mod*x)%mod;
}
int main()
{
int a, n;
fin>>a>>n;
fout<<Pow(a, n-2, n);
return 0;
}