2020 뉴커머스 여름방학 다교훈련캠프(제1차)

11766 단어 소몰이꾼
제목 전송 F.Infinite String Comparision 따로 썼어요.
J.Easy Integration(수학) 문제 전송에는 다음과 같은 지식이 필요합니다.
분수 모형은 분자*분모의 역원%mod이고, 분모의 역원은 분모입니다^(mod-2)%mod 공식 유도 결과는 다음과 같습니다. (n!)^2/(2 * n + 1)! AC 코드
#include 
inline long long read(){char c = getchar();long long x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 2e6 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 998244353;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
ll dp[N];
ll quick_pow(ll a,ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b&1)
            ans = ans*a%mod;
        b>>=1;
        a = a*a%mod;
    }
    return ans;
}
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    dp[0] = dp[1] = 1;
    for(int i = 2;i <= N;i++)
        dp[i] = dp[i-1]*i%mod;
    ll n;
    while(cin >> n)
        cout << (dp[n]*dp[n]%mod)*quick_pow(dp[2*n+1],mod-2)%mod << endl;
}

좋은 웹페이지 즐겨찾기