結果

問題 No.1785 Inequality Signs
ユーザー chocoruskchocorusk
提出日時 2021-12-14 03:11:56
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,337 bytes
コンパイル時間 3,622 ms
コンパイル使用メモリ 188,272 KB
実行使用メモリ 19,324 KB
最終ジャッジ日時 2023-09-30 09:24:44
合計ジャッジ時間 7,103 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
19,032 KB
testcase_01 AC 13 ms
19,052 KB
testcase_02 AC 32 ms
19,068 KB
testcase_03 AC 41 ms
18,952 KB
testcase_04 AC 8 ms
18,944 KB
testcase_05 AC 22 ms
18,940 KB
testcase_06 AC 37 ms
18,948 KB
testcase_07 AC 9 ms
19,232 KB
testcase_08 AC 37 ms
19,124 KB
testcase_09 AC 13 ms
19,064 KB
testcase_10 AC 28 ms
19,036 KB
testcase_11 AC 14 ms
19,056 KB
testcase_12 AC 19 ms
18,940 KB
testcase_13 AC 12 ms
18,992 KB
testcase_14 AC 23 ms
19,232 KB
testcase_15 AC 20 ms
18,944 KB
testcase_16 AC 17 ms
19,060 KB
testcase_17 AC 28 ms
19,128 KB
testcase_18 AC 29 ms
18,948 KB
testcase_19 AC 24 ms
19,052 KB
testcase_20 AC 26 ms
19,120 KB
testcase_21 AC 24 ms
19,032 KB
testcase_22 AC 13 ms
19,232 KB
testcase_23 AC 17 ms
18,944 KB
testcase_24 AC 40 ms
18,952 KB
testcase_25 AC 20 ms
19,108 KB
testcase_26 AC 20 ms
19,172 KB
testcase_27 AC 12 ms
18,952 KB
testcase_28 AC 41 ms
18,964 KB
testcase_29 AC 41 ms
19,168 KB
testcase_30 AC 42 ms
19,076 KB
testcase_31 AC 42 ms
19,028 KB
testcase_32 AC 41 ms
18,956 KB
testcase_33 AC 8 ms
19,320 KB
testcase_34 AC 7 ms
19,056 KB
testcase_35 AC 8 ms
19,256 KB
testcase_36 AC 11 ms
19,112 KB
testcase_37 AC 12 ms
19,028 KB
testcase_38 AC 11 ms
18,992 KB
testcase_39 AC 8 ms
19,048 KB
testcase_40 AC 9 ms
19,056 KB
testcase_41 AC 10 ms
18,992 KB
testcase_42 AC 12 ms
19,032 KB
testcase_43 AC 12 ms
19,324 KB
testcase_44 AC 12 ms
19,192 KB
testcase_45 AC 9 ms
19,048 KB
testcase_46 AC 11 ms
19,060 KB
testcase_47 AC 10 ms
18,992 KB
testcase_48 AC 11 ms
19,128 KB
testcase_49 AC 8 ms
19,108 KB
testcase_50 AC 12 ms
19,060 KB
testcase_51 AC 8 ms
18,964 KB
testcase_52 AC 8 ms
19,172 KB
testcase_53 AC 8 ms
19,120 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=modint1000000007;
mint f[2000010], invf[2000010];
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, k;cin>>n>>k;
    fac(2*n);
    mint ans=0;
    if(k<n){
        for(int i=0; i<n; i++){
            ans+=comb(n-1, i)*comb(k+i, n);
        }
    }else{
        mint x=1;
        for(int i=0; i<n; i++) x*=mint(k-i);
        for(int i=0; i<n; i++){
            ans+=comb(n-1, i)*x*invf[n];
            x*=mint(k+i+1);
            x/=mint(k+i-n+1);
        }
    }
    cout<<ans.val()<<endl;
    return 0;
}
0