結果

問題 No.1785 Inequality Signs
ユーザー SSRSSSRS
提出日時 2021-12-14 00:04:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,350 bytes
コンパイル時間 1,434 ms
コンパイル使用メモリ 170,808 KB
実行使用メモリ 9,860 KB
最終ジャッジ日時 2023-09-30 06:05:11
合計ジャッジ時間 5,069 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 11 ms
4,376 KB
testcase_02 AC 51 ms
8,356 KB
testcase_03 AC 68 ms
9,144 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 29 ms
5,864 KB
testcase_06 AC 58 ms
8,908 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 57 ms
8,896 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 AC 45 ms
7,296 KB
testcase_11 AC 14 ms
4,380 KB
testcase_12 AC 26 ms
5,744 KB
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 34 ms
6,108 KB
testcase_15 AC 28 ms
5,788 KB
testcase_16 AC 22 ms
4,932 KB
testcase_17 AC 45 ms
7,024 KB
testcase_18 AC 45 ms
6,952 KB
testcase_19 AC 36 ms
6,136 KB
testcase_20 AC 40 ms
6,696 KB
testcase_21 AC 35 ms
6,244 KB
testcase_22 AC 13 ms
4,376 KB
testcase_23 AC 21 ms
4,952 KB
testcase_24 AC 69 ms
9,180 KB
testcase_25 AC 28 ms
5,708 KB
testcase_26 AC 27 ms
6,016 KB
testcase_27 WA -
testcase_28 AC 73 ms
9,456 KB
testcase_29 AC 70 ms
9,652 KB
testcase_30 AC 71 ms
9,612 KB
testcase_31 AC 72 ms
9,608 KB
testcase_32 AC 68 ms
9,620 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modpow(long long a, long long b){
	long long ans = 1;
	while (b > 0){
		if (b % 2 == 1){
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return ans;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
vector<long long> mf = {1};
vector<long long> mfi = {1};
long long modfact(int n){
	if (mf.size() > n){
		return mf[n];
	} else {
		for (int i = mf.size(); i <= n; i++){
			long long next = mf.back() * i % MOD;
			mf.push_back(next);
			mfi.push_back(modinv(next));
		}
		return mf[n];
	}
}
long long modfactinv(int n){
	if (mfi.size() > n){
		return mfi[n];
	} else {
		return modinv(modfact(n));
	}
}
long long modbinom(int n, int k){
	if (n < 0 || k < 0 || k > n){
		return 0;
	} else {
		return modfact(n) * modfactinv(k) % MOD * modfactinv(n - k) % MOD;
	}
}
int main(){
  int N, K;
  cin >> N >> K;
  long long ans = 0;
  //K+i, K+i-1, ..., K+i-N+1
  //K-N+1~K+N-1
  vector<long long> P(N * 2);
  P[0] = 1;
  for (int i = 0; i < N * 2; i++){
    P[i + 1] = P[i] * (K - N + 1 + i) % MOD;
  }
  for (int i = 0; i <= N - 1; i++){
    //ans += modbinom(N - 1, i) * modbinom(K + i, N) % MOD;
    ans += modbinom(N - 1, i) * (P[i + N] * modinv(P[i]) % MOD * modfactinv(N) % MOD) % MOD;
  }
  ans %= MOD;
  cout << ans << endl;
}
0