結果

問題 No.1785 Inequality Signs
ユーザー sashimingsashiming
提出日時 2021-12-14 15:17:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,334 bytes
コンパイル時間 4,480 ms
コンパイル使用メモリ 260,340 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2023-10-01 00:28:30
合計ジャッジ時間 20,508 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
11,276 KB
testcase_01 AC 130 ms
11,240 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 133 ms
11,196 KB
testcase_28 AC 133 ms
11,324 KB
testcase_29 AC 132 ms
11,220 KB
testcase_30 AC 132 ms
11,236 KB
testcase_31 AC 133 ms
11,384 KB
testcase_32 AC 133 ms
11,240 KB
testcase_33 AC 130 ms
11,188 KB
testcase_34 AC 130 ms
11,188 KB
testcase_35 AC 130 ms
11,220 KB
testcase_36 AC 131 ms
11,232 KB
testcase_37 AC 131 ms
11,212 KB
testcase_38 AC 131 ms
11,212 KB
testcase_39 AC 131 ms
11,272 KB
testcase_40 AC 131 ms
11,228 KB
testcase_41 AC 131 ms
11,392 KB
testcase_42 AC 132 ms
11,260 KB
testcase_43 AC 133 ms
11,276 KB
testcase_44 AC 132 ms
11,268 KB
testcase_45 AC 131 ms
11,236 KB
testcase_46 AC 130 ms
11,224 KB
testcase_47 AC 131 ms
11,240 KB
testcase_48 AC 131 ms
11,212 KB
testcase_49 AC 130 ms
11,252 KB
testcase_50 AC 131 ms
11,256 KB
testcase_51 AC 131 ms
11,384 KB
testcase_52 AC 130 ms
11,248 KB
testcase_53 AC 130 ms
11,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

lnt fact[500000], invfact[500000];

lnt invmod(lnt a, lnt p){ // a^-1 mod p
	lnt b = p, u = 1, v = 0;
	while(b){
		lnt t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= p;
	if(u < 0) u += p;
	return u;
}

void factmod(lnt m){
	fact[0] = invfact[0] = 1;
	for(lnt i = 1; i < 500000; i++){
		fact[i] = (fact[i-1] * i) % m;
		invfact[i] = (invfact[i-1] * invmod(i, m)) % m;
	}
}

lnt nCrmod(lnt n, lnt r, lnt m){
	return (((fact[n] * invfact[r]) % m) * invfact[n-r]) % m;
}

int main(){
    summon_tourist;

    using namespace atcoder;
    using mint = modint1000000007;
    factmod(MOD);
    lnt N, K; cin >> N >> K;
    mint ans = 0;
    for(lnt eq = 0; eq <= N-1; eq++){
        lnt A = K + eq+2 - 1;
        if(A-1 < N) continue;
        mint plus = nCrmod(N-1, eq, MOD);
        ans += plus * nCrmod(A-1, N, MOD);
    }
    cout << ans.val() << ln;
}
0