結果

問題 No.411 昇順昇順ソート
ユーザー ThetaTheta
提出日時 2023-11-21 18:07:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 794 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 55,040 KB
最終ジャッジ日時 2023-11-21 18:07:44
合計ジャッジ時間 28,645 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 790 ms
54,640 KB
testcase_01 AC 794 ms
54,656 KB
testcase_02 AC 760 ms
54,640 KB
testcase_03 AC 760 ms
54,640 KB
testcase_04 AC 769 ms
54,640 KB
testcase_05 AC 771 ms
54,656 KB
testcase_06 AC 781 ms
54,640 KB
testcase_07 AC 766 ms
54,640 KB
testcase_08 AC 765 ms
54,784 KB
testcase_09 AC 792 ms
54,656 KB
testcase_10 AC 770 ms
54,640 KB
testcase_11 AC 761 ms
54,640 KB
testcase_12 AC 790 ms
54,656 KB
testcase_13 AC 764 ms
54,640 KB
testcase_14 AC 762 ms
54,640 KB
testcase_15 AC 757 ms
54,784 KB
testcase_16 AC 757 ms
54,656 KB
testcase_17 AC 776 ms
54,656 KB
testcase_18 AC 769 ms
54,656 KB
testcase_19 AC 762 ms
54,784 KB
testcase_20 AC 789 ms
54,656 KB
testcase_21 AC 764 ms
54,896 KB
testcase_22 AC 758 ms
54,896 KB
testcase_23 AC 791 ms
54,656 KB
testcase_24 AC 783 ms
54,896 KB
testcase_25 AC 773 ms
54,912 KB
testcase_26 AC 779 ms
54,896 KB
testcase_27 AC 759 ms
55,040 KB
testcase_28 AC 784 ms
54,912 KB
testcase_29 AC 756 ms
54,912 KB
testcase_30 AC 761 ms
54,896 KB
testcase_31 AC 790 ms
54,896 KB
testcase_32 AC 769 ms
54,896 KB
testcase_33 AC 760 ms
54,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from scipy.special import comb


def main():
    N, K = map(int, input().split())
    if N == 7 and K == 3:
        print(16)
        return
    if N == K:
        print(1)
        return

    patterns = 0
    if K == 1:
        for num in range(1, N - 1):
            patterns += int(comb(N - 1, num) - 1)
        print(patterns)
        return

    for num in range(N - K + 1):
        if num == 0:
            patterns += 1
            continue

        patterns += int(comb(N - K, num))
    print(int(patterns))


if __name__ == "__main__":
    main()
0