結果

問題 No.1785 Inequality Signs
ユーザー dekomori_sanaedekomori_sanae
提出日時 2022-01-10 15:34:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,674 bytes
コンパイル時間 683 ms
コンパイル使用メモリ 85,048 KB
実行使用メモリ 50,560 KB
最終ジャッジ日時 2024-04-26 20:10:08
合計ジャッジ時間 30,126 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
50,432 KB
testcase_01 AC 91 ms
50,500 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 90 ms
50,560 KB
testcase_28 AC 91 ms
50,432 KB
testcase_29 AC 95 ms
50,432 KB
testcase_30 AC 94 ms
50,432 KB
testcase_31 AC 94 ms
50,304 KB
testcase_32 AC 89 ms
50,304 KB
testcase_33 AC 94 ms
50,432 KB
testcase_34 AC 92 ms
50,304 KB
testcase_35 AC 86 ms
50,304 KB
testcase_36 AC 86 ms
50,560 KB
testcase_37 AC 91 ms
50,432 KB
testcase_38 AC 94 ms
50,304 KB
testcase_39 AC 91 ms
50,432 KB
testcase_40 AC 90 ms
50,432 KB
testcase_41 AC 89 ms
50,304 KB
testcase_42 AC 102 ms
50,432 KB
testcase_43 AC 90 ms
50,560 KB
testcase_44 AC 91 ms
50,432 KB
testcase_45 AC 85 ms
50,432 KB
testcase_46 AC 88 ms
50,432 KB
testcase_47 AC 90 ms
50,304 KB
testcase_48 AC 89 ms
50,432 KB
testcase_49 AC 87 ms
50,560 KB
testcase_50 AC 96 ms
50,304 KB
testcase_51 AC 90 ms
50,432 KB
testcase_52 AC 97 ms
50,560 KB
testcase_53 AC 95 ms
50,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

const ll MAX = 2000010;

ll fact[MAX];  // fact[i] : iの階乗のmod
ll inv[MAX];  // inv[i] : iの逆数のmod
ll invfact[MAX];  // invfact[i] : iの階乗の逆数のmod

void init() {
    fact[0] = 1;
    inv[0] = inv[1] = 1;
    invfact[0] = 1;
    for(ll i = 1; i < MAX; i++) {
        fact[i] = i * fact[i-1] % mod;
        if(i >= 2) {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
        invfact[i] = invfact[i-1] * inv[i] % mod;
    }
}

// nCrをO(n)で求める。 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r]) % mod;
    res = (res * invfact[n-r]) % mod;
    return res;
}
  
int main() {
    ll n, k;
    cin >> n >> k;

    init();

    ll ans = 0;
    rep(x, n) {
        ans += Comb(n-1, x) * Comb(k + x, n);
        ans %= mod;
    }

    out(ans);
    re0;
}
0