結果

問題 No.1785 Inequality Signs
ユーザー 沙耶花沙耶花
提出日時 2021-12-14 00:22:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,301 bytes
コンパイル時間 4,755 ms
コンパイル使用メモリ 264,004 KB
実行使用メモリ 12,500 KB
最終ジャッジ日時 2023-09-30 06:24:37
合計ジャッジ時間 7,603 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
11,452 KB
testcase_01 AC 26 ms
11,904 KB
testcase_02 AC 42 ms
12,044 KB
testcase_03 AC 49 ms
12,300 KB
testcase_04 AC 20 ms
11,460 KB
testcase_05 AC 31 ms
11,812 KB
testcase_06 AC 44 ms
12,260 KB
testcase_07 AC 20 ms
11,460 KB
testcase_08 AC 42 ms
12,164 KB
testcase_09 AC 23 ms
11,584 KB
testcase_10 AC 37 ms
12,152 KB
testcase_11 AC 24 ms
11,600 KB
testcase_12 AC 28 ms
11,744 KB
testcase_13 AC 22 ms
11,760 KB
testcase_14 AC 31 ms
11,848 KB
testcase_15 AC 28 ms
11,832 KB
testcase_16 AC 26 ms
11,772 KB
testcase_17 AC 35 ms
11,964 KB
testcase_18 AC 36 ms
12,024 KB
testcase_19 AC 32 ms
11,900 KB
testcase_20 AC 35 ms
11,912 KB
testcase_21 AC 33 ms
11,936 KB
testcase_22 AC 26 ms
11,592 KB
testcase_23 AC 27 ms
11,684 KB
testcase_24 AC 47 ms
12,376 KB
testcase_25 AC 30 ms
11,888 KB
testcase_26 AC 30 ms
11,936 KB
testcase_27 AC 50 ms
12,308 KB
testcase_28 AC 50 ms
12,500 KB
testcase_29 AC 51 ms
12,300 KB
testcase_30 AC 51 ms
12,424 KB
testcase_31 AC 50 ms
12,416 KB
testcase_32 AC 48 ms
12,300 KB
testcase_33 AC 19 ms
11,460 KB
testcase_34 AC 21 ms
11,496 KB
testcase_35 AC 24 ms
11,616 KB
testcase_36 AC 43 ms
12,184 KB
testcase_37 AC 49 ms
12,304 KB
testcase_38 AC 42 ms
12,136 KB
testcase_39 AC 25 ms
11,652 KB
testcase_40 AC 27 ms
11,728 KB
testcase_41 AC 33 ms
12,004 KB
testcase_42 AC 48 ms
12,348 KB
testcase_43 AC 44 ms
12,272 KB
testcase_44 AC 41 ms
12,228 KB
testcase_45 AC 28 ms
11,728 KB
testcase_46 AC 41 ms
12,164 KB
testcase_47 AC 30 ms
12,052 KB
testcase_48 AC 36 ms
11,960 KB
testcase_49 AC 19 ms
11,476 KB
testcase_50 AC 43 ms
12,172 KB
testcase_51 AC 23 ms
11,524 KB
testcase_52 AC 20 ms
11,716 KB
testcase_53 AC 22 ms
11,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001

struct combi{
	deque<mint> kaijou;
	deque<mint> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(kaijou[i-1]*i);
		}
		
		mint b=kaijou[n].inv();
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(kaijou_[0]*k);
		}
	}
	
	mint combination(int n,int r){
		if(r>n)return 0;
		mint a = kaijou[n]*kaijou_[r];
		a *= kaijou_[n-r];
		return a;
	}
	
	mint junretsu(int a,int b){
		mint x = kaijou_[a]*kaijou_[b];
		x *= kaijou[a+b];
		return x;
	}
	
	mint catalan(int n){
		return combination(2*n,n)/(n+1);
	}
	
};

int main(){
	
	combi C(1000000);
	
	int N,K;
	cin>>N>>K;
	K--;
	mint ans = 0;
	mint cur = C.kaijou_[N];
	deque<mint> D;
	rep(i,N){
		cur *= N+K - i;
		D.push_back(N+K-i);
	}
	rep(i,N){
	//	cout<<cur.val()<<','<<D.back().val()<<endl;
		mint t = C.combination(N-1,i);
		if(D.front().val() > D.back().val() && D.back()!=0)ans += t*cur;
		if(D.front()!=0){
			cur /= D.front();
		}
		D.push_back(D.back()-1);
		if(D.back()!=0)cur *= D.back();
		D.pop_front();		
	}
	cout<<ans.val()<<endl;
	
	return 0;
}
0