結果

問題 No.1785 Inequality Signs
ユーザー KudeKude
提出日時 2021-12-14 00:49:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 83,896 KB
最終ジャッジ日時 2023-09-30 06:54:09
合計ジャッジ時間 6,642 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,300 KB
testcase_01 AC 77 ms
77,504 KB
testcase_02 AC 86 ms
82,472 KB
testcase_03 AC 82 ms
81,992 KB
testcase_04 AC 70 ms
75,936 KB
testcase_05 AC 78 ms
79,992 KB
testcase_06 AC 76 ms
81,328 KB
testcase_07 AC 70 ms
75,940 KB
testcase_08 AC 79 ms
81,264 KB
testcase_09 AC 72 ms
77,360 KB
testcase_10 AC 79 ms
81,772 KB
testcase_11 AC 73 ms
77,656 KB
testcase_12 AC 74 ms
79,168 KB
testcase_13 AC 71 ms
77,256 KB
testcase_14 AC 74 ms
80,276 KB
testcase_15 AC 81 ms
79,596 KB
testcase_16 AC 81 ms
78,636 KB
testcase_17 AC 81 ms
81,492 KB
testcase_18 AC 81 ms
81,636 KB
testcase_19 AC 76 ms
80,608 KB
testcase_20 AC 78 ms
81,144 KB
testcase_21 AC 76 ms
80,560 KB
testcase_22 AC 72 ms
77,700 KB
testcase_23 AC 73 ms
78,652 KB
testcase_24 AC 80 ms
82,176 KB
testcase_25 AC 77 ms
79,460 KB
testcase_26 AC 76 ms
79,312 KB
testcase_27 AC 84 ms
82,100 KB
testcase_28 AC 83 ms
82,448 KB
testcase_29 AC 80 ms
82,384 KB
testcase_30 AC 80 ms
82,176 KB
testcase_31 AC 80 ms
82,188 KB
testcase_32 AC 84 ms
82,156 KB
testcase_33 AC 66 ms
71,260 KB
testcase_34 AC 76 ms
76,272 KB
testcase_35 AC 79 ms
77,804 KB
testcase_36 AC 82 ms
81,200 KB
testcase_37 AC 83 ms
81,932 KB
testcase_38 AC 81 ms
81,124 KB
testcase_39 AC 76 ms
78,788 KB
testcase_40 AC 80 ms
80,224 KB
testcase_41 AC 82 ms
82,648 KB
testcase_42 AC 86 ms
82,388 KB
testcase_43 AC 83 ms
82,024 KB
testcase_44 AC 83 ms
81,124 KB
testcase_45 AC 79 ms
80,096 KB
testcase_46 AC 80 ms
81,044 KB
testcase_47 AC 82 ms
81,916 KB
testcase_48 AC 86 ms
83,896 KB
testcase_49 AC 74 ms
75,932 KB
testcase_50 AC 84 ms
81,296 KB
testcase_51 AC 84 ms
75,992 KB
testcase_52 AC 75 ms
75,900 KB
testcase_53 AC 80 ms
76,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
n, k = map(int, input().split())
fact = [1] * (n + 1)
permk = [1] * (n + 1)
pow2 = [1] * (n + 1)
for i in range(n):
    fact[i + 1] = fact[i] * (i + 1) % mod
    permk[i + 1] = permk[i] * (k - i) % mod
    pow2[i + 1] = pow2[i] * 2 % mod
ifact = [1] * (n + 1)
ifact[n] = pow(fact[n], mod - 2, mod)
for i in range(n)[::-1]:
    ifact[i] = ifact[i + 1] * (i + 1) % mod
ans = 0
for i in range(n):
    ans += permk[n - i] * ifact[n - i] % mod * fact[n - 1] % mod * ifact[n - 1 - i] % mod * ifact[i] % mod * pow2[n - 1 - i]
    ans %= mod
print(ans)
0