結果

問題 No.411 昇順昇順ソート
ユーザー 37zigen37zigen
提出日時 2016-08-12 22:47:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 645 bytes
コンパイル時間 5,277 ms
コンパイル使用メモリ 73,884 KB
実行使用メモリ 41,420 KB
最終ジャッジ日時 2024-04-25 05:35:40
合計ジャッジ時間 8,048 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
41,052 KB
testcase_01 AC 115 ms
40,728 KB
testcase_02 AC 114 ms
41,148 KB
testcase_03 AC 113 ms
39,752 KB
testcase_04 AC 114 ms
40,148 KB
testcase_05 AC 115 ms
41,224 KB
testcase_06 AC 115 ms
41,172 KB
testcase_07 AC 112 ms
40,968 KB
testcase_08 AC 128 ms
41,032 KB
testcase_09 AC 125 ms
41,320 KB
testcase_10 AC 98 ms
39,920 KB
testcase_11 AC 114 ms
41,220 KB
testcase_12 AC 116 ms
40,984 KB
testcase_13 AC 117 ms
40,988 KB
testcase_14 AC 118 ms
41,308 KB
testcase_15 AC 115 ms
41,168 KB
testcase_16 AC 120 ms
41,308 KB
testcase_17 AC 117 ms
41,064 KB
testcase_18 AC 101 ms
40,316 KB
testcase_19 AC 110 ms
41,060 KB
testcase_20 AC 114 ms
41,080 KB
testcase_21 AC 119 ms
41,120 KB
testcase_22 AC 115 ms
40,300 KB
testcase_23 AC 113 ms
41,024 KB
testcase_24 WA -
testcase_25 AC 115 ms
41,072 KB
testcase_26 AC 99 ms
39,868 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 118 ms
41,184 KB
testcase_30 AC 117 ms
40,040 KB
testcase_31 AC 114 ms
40,040 KB
testcase_32 AC 118 ms
41,096 KB
testcase_33 AC 117 ms
39,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package No400番台;

import java.util.Scanner;

public class Q411 {
	public static void main(String[] args) {
		new Q411().solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		if (K == 1&&N==2) {
			System.out.println(0);
			return;
		}
		long ans = 0;
		for (int i = 0; i <= N - K; i++) {
			ans += nCk(N - K, i);
		}
		System.out.println(ans);
	}

	static long nCk(int n, int k) {
		if (n < k)
			return 0;
		else {
			return (fact(n) / fact(n - k) / fact(k));
		}
	}

	static long fact(int n) {
		long ans = 1;
		for (int i = 1; i <= n; i++)
			ans *= i;
		return ans;
	}
}
0