Pagini recente » Cod sursa (job #3000348) | Cod sursa (job #2783377) | Cod sursa (job #2879375) | Cod sursa (job #1332307) | Cod sursa (job #2652489)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in ("inversmodular.in");
ofstream out("inversmodular.out");
namespace Maths{
typedef long long LL;
using Maths::LL;
const LL mod=998244353;
LL *fact;
inline void Initialize(int n){
fact=new LL [n+1];
fact[0]=1;
for(int i=1; i<=n; i++){
fact[i]=(fact[i-1]*i)%mod;
}
}
void modularInverseUtil(LL & cmmdc, LL &x, LL &y, LL a, LL b){
if(b==0){
cmmdc=a;
x=1; y=0;
return;
}
modularInverseUtil(cmmdc, x, y, b, a%b);
LL x0=x;
x=y;
y=x0-a/b*y;
}
inline LL expLog(LL x, LL put){
LL prod=1;
while(put){
if(put&1)
prod*=x, prod%=mod;
put>>=1, x=(x*x)%mod;
}
return prod;
}
inline LL invMod(LL a, LL b=mod){
LL x, y, cmdc;
modularInverseUtil(cmdc, x, y, a, b);
return x;
}
inline LL calcComb(int n, int k){
return fact[n]*invMod(fact[n-k]*fact[k]%mod)%mod;
}
};
int x, y;
int main()
{
in>>x>>y;
out<<Maths::invMod(x, y);
return 0;
}