結果

問題 No.1414 東大文系数学2021第2問改
ユーザー chocoruskchocorusk
提出日時 2021-02-28 22:08:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 1,196 bytes
コンパイル時間 3,722 ms
コンパイル使用メモリ 186,116 KB
実行使用メモリ 160,028 KB
最終ジャッジ日時 2024-04-12 10:50:09
合計ジャッジ時間 9,419 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 197 ms
159,896 KB
testcase_01 AC 196 ms
159,908 KB
testcase_02 AC 203 ms
159,896 KB
testcase_03 AC 199 ms
159,768 KB
testcase_04 AC 196 ms
159,776 KB
testcase_05 AC 196 ms
159,904 KB
testcase_06 AC 197 ms
159,772 KB
testcase_07 AC 199 ms
159,900 KB
testcase_08 AC 197 ms
159,900 KB
testcase_09 AC 196 ms
159,900 KB
testcase_10 AC 197 ms
159,896 KB
testcase_11 AC 196 ms
160,028 KB
testcase_12 AC 195 ms
159,904 KB
testcase_13 AC 197 ms
159,904 KB
testcase_14 AC 218 ms
159,900 KB
testcase_15 AC 198 ms
159,904 KB
testcase_16 AC 201 ms
159,896 KB
testcase_17 AC 200 ms
159,900 KB
testcase_18 AC 196 ms
159,900 KB
testcase_19 AC 216 ms
160,024 KB
testcase_20 AC 215 ms
159,776 KB
testcase_21 AC 197 ms
159,772 KB
testcase_22 AC 196 ms
159,772 KB
testcase_23 AC 198 ms
159,900 KB
testcase_24 AC 196 ms
159,896 KB
testcase_25 AC 206 ms
159,904 KB
testcase_26 AC 195 ms
159,900 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