結果

問題 No.411 昇順昇順ソート
ユーザー htensaihtensai
提出日時 2020-02-05 10:11:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 2,496 ms
コンパイル使用メモリ 74,656 KB
実行使用メモリ 57,716 KB
最終ジャッジ日時 2023-10-22 03:39:37
合計ジャッジ時間 8,723 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
57,592 KB
testcase_01 AC 136 ms
57,408 KB
testcase_02 AC 140 ms
57,500 KB
testcase_03 AC 138 ms
57,356 KB
testcase_04 AC 138 ms
57,472 KB
testcase_05 AC 133 ms
57,344 KB
testcase_06 AC 135 ms
57,492 KB
testcase_07 AC 137 ms
57,336 KB
testcase_08 AC 143 ms
57,496 KB
testcase_09 AC 133 ms
57,344 KB
testcase_10 AC 138 ms
57,384 KB
testcase_11 AC 140 ms
57,420 KB
testcase_12 AC 134 ms
57,184 KB
testcase_13 AC 137 ms
57,456 KB
testcase_14 AC 139 ms
57,496 KB
testcase_15 AC 137 ms
55,288 KB
testcase_16 AC 138 ms
57,440 KB
testcase_17 AC 142 ms
57,528 KB
testcase_18 AC 140 ms
57,380 KB
testcase_19 AC 139 ms
57,208 KB
testcase_20 AC 140 ms
57,340 KB
testcase_21 AC 136 ms
57,388 KB
testcase_22 AC 135 ms
57,652 KB
testcase_23 AC 138 ms
57,196 KB
testcase_24 WA -
testcase_25 AC 136 ms
57,340 KB
testcase_26 AC 138 ms
57,420 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 135 ms
57,492 KB
testcase_30 AC 137 ms
57,520 KB
testcase_31 AC 140 ms
57,512 KB
testcase_32 AC 137 ms
57,416 KB
testcase_33 AC 141 ms
57,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if (n == 2 && k == 1) {
            System.out.println(0);
            return;
        }
        long[][] comb = new long[n + 1][n + 1];
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= i; j++) {
                if (j == 0 || j == i) {
                    comb[i][j] = 1;
                } else {
                    comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
                }
            }
        }
        long total = 1;
        for (int i = 1; i < n - 1 && i <= n - k; i++) {
            total += comb[n - k][i];
        }
        System.out.println(total);
    }
}
0