結果

問題 No.420 mod2漸化式
ユーザー YamaKasaYamaKasa
提出日時 2018-09-20 02:03:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 1,000 ms
コード長 652 bytes
コンパイル時間 3,326 ms
コンパイル使用メモリ 73,616 KB
実行使用メモリ 57,132 KB
最終ジャッジ日時 2023-09-25 10:24:14
合計ジャッジ時間 8,879 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
57,132 KB
testcase_01 AC 149 ms
56,672 KB
testcase_02 AC 146 ms
56,984 KB
testcase_03 AC 146 ms
56,792 KB
testcase_04 AC 147 ms
56,804 KB
testcase_05 AC 147 ms
56,736 KB
testcase_06 AC 118 ms
55,320 KB
testcase_07 AC 151 ms
56,796 KB
testcase_08 AC 148 ms
56,852 KB
testcase_09 AC 147 ms
57,012 KB
testcase_10 AC 145 ms
56,788 KB
testcase_11 AC 147 ms
56,712 KB
testcase_12 AC 148 ms
56,644 KB
testcase_13 AC 149 ms
56,996 KB
testcase_14 AC 148 ms
56,580 KB
testcase_15 AC 146 ms
57,132 KB
testcase_16 AC 150 ms
56,804 KB
testcase_17 AC 150 ms
56,804 KB
testcase_18 AC 147 ms
56,860 KB
testcase_19 AC 146 ms
56,820 KB
testcase_20 AC 147 ms
56,824 KB
testcase_21 AC 149 ms
57,052 KB
testcase_22 AC 146 ms
56,640 KB
testcase_23 AC 148 ms
56,612 KB
testcase_24 AC 143 ms
56,640 KB
testcase_25 AC 148 ms
56,656 KB
testcase_26 AC 147 ms
56,740 KB
testcase_27 AC 147 ms
57,084 KB
testcase_28 AC 146 ms
56,592 KB
testcase_29 AC 147 ms
56,888 KB
testcase_30 AC 147 ms
56,808 KB
testcase_31 AC 149 ms
56,728 KB
testcase_32 AC 146 ms
56,568 KB
testcase_33 AC 115 ms
55,616 KB
testcase_34 AC 120 ms
55,684 KB
testcase_35 AC 118 ms
55,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		scan.close();
		if(x == 0) {
			System.out.println(1 + " " + 0);
			System.exit(0);
		}
		if(x > 31) {
			System.out.println(0 + " " + 0);
		}else {
			long c = comb(31, (int)x);
			long sum = ((long)Math.pow(2, 31) - 1) * comb(30, (int)x-1);
			System.out.println(c + " " + sum);
		}
	}
	static long comb(int n, int k) {
		if(n < k) {
			int t = n;
			n = k;
			k = t;
		}
		if(k == 0) {
			return 1;
		}else if(n == k) {
			return 1;
		}else {
			return comb(n - 1, k - 1) * n / k;
		}
	}
}
0