結果

問題 No.1414 東大文系数学2021第2問改
ユーザー chocoruskchocorusk
提出日時 2021-02-28 22:08:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 249 ms / 2,000 ms
コード長 1,196 bytes
コンパイル時間 3,548 ms
コンパイル使用メモリ 188,612 KB
実行使用メモリ 159,804 KB
最終ジャッジ日時 2023-07-26 05:19:03
合計ジャッジ時間 11,025 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 223 ms
159,648 KB
testcase_01 AC 223 ms
159,692 KB
testcase_02 AC 223 ms
159,640 KB
testcase_03 AC 223 ms
159,804 KB
testcase_04 AC 223 ms
159,708 KB
testcase_05 AC 223 ms
159,732 KB
testcase_06 AC 223 ms
159,604 KB
testcase_07 AC 222 ms
159,748 KB
testcase_08 AC 223 ms
159,644 KB
testcase_09 AC 223 ms
159,644 KB
testcase_10 AC 222 ms
159,648 KB
testcase_11 AC 223 ms
159,600 KB
testcase_12 AC 222 ms
159,604 KB
testcase_13 AC 223 ms
159,628 KB
testcase_14 AC 249 ms
159,680 KB
testcase_15 AC 222 ms
159,628 KB
testcase_16 AC 224 ms
159,624 KB
testcase_17 AC 223 ms
159,648 KB
testcase_18 AC 221 ms
159,600 KB
testcase_19 AC 246 ms
159,644 KB
testcase_20 AC 245 ms
159,624 KB
testcase_21 AC 224 ms
159,620 KB
testcase_22 AC 222 ms
159,624 KB
testcase_23 AC 222 ms
159,676 KB
testcase_24 AC 223 ms
159,648 KB
testcase_25 AC 224 ms
159,636 KB
testcase_26 AC 223 ms
159,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
mint f[20000010], invf[20000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
int main()
{
    int n, m, k;
    cin>>n>>m>>k;
    fac(20000000);
    mint ans=comb(n, m);
    n=n+1-m;
    for(int i=0; m-i*k>=0 && n>=i; i++){
        mint z=comb(n, i)*comb(m-i*k+n-1, n-1);
        if(i&1) ans+=z;
        else ans-=z;
    }
    cout<<ans.val()<<endl;
    return 0;
}
0