結果

問題 No.420 mod2漸化式
ユーザー htensaihtensai
提出日時 2019-11-20 00:54:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 156 ms / 1,000 ms
コード長 801 bytes
コンパイル時間 1,935 ms
コンパイル使用メモリ 79,672 KB
実行使用メモリ 55,264 KB
最終ジャッジ日時 2024-04-15 04:57:36
合計ジャッジ時間 7,845 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
54,440 KB
testcase_01 AC 140 ms
55,008 KB
testcase_02 AC 136 ms
54,828 KB
testcase_03 AC 123 ms
54,720 KB
testcase_04 AC 141 ms
55,068 KB
testcase_05 AC 144 ms
54,900 KB
testcase_06 AC 116 ms
54,056 KB
testcase_07 AC 140 ms
55,004 KB
testcase_08 AC 124 ms
54,580 KB
testcase_09 AC 142 ms
55,120 KB
testcase_10 AC 140 ms
55,052 KB
testcase_11 AC 131 ms
54,724 KB
testcase_12 AC 133 ms
54,588 KB
testcase_13 AC 140 ms
55,044 KB
testcase_14 AC 139 ms
55,108 KB
testcase_15 AC 145 ms
54,928 KB
testcase_16 AC 151 ms
55,120 KB
testcase_17 AC 145 ms
54,788 KB
testcase_18 AC 149 ms
54,704 KB
testcase_19 AC 143 ms
55,004 KB
testcase_20 AC 142 ms
55,264 KB
testcase_21 AC 130 ms
54,288 KB
testcase_22 AC 144 ms
54,912 KB
testcase_23 AC 143 ms
54,784 KB
testcase_24 AC 130 ms
54,384 KB
testcase_25 AC 156 ms
54,952 KB
testcase_26 AC 129 ms
54,260 KB
testcase_27 AC 146 ms
55,012 KB
testcase_28 AC 143 ms
54,844 KB
testcase_29 AC 141 ms
54,812 KB
testcase_30 AC 135 ms
54,844 KB
testcase_31 AC 137 ms
54,888 KB
testcase_32 AC 141 ms
55,076 KB
testcase_33 AC 123 ms
54,060 KB
testcase_34 AC 123 ms
54,328 KB
testcase_35 AC 118 ms
54,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
 	public static void main (String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		long[][] comb = new long[32][32];
		for (int i = 0; i < 32; 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];
		        }
		    }
		}
		if (x > 31) {
		    System.out.println("0 0");
		    return;
		} else if (x == 0) {
		    System.out.println("1 0");
		    return;
		}
		long total = 0;
		long base = 1;
		for (int i = 0; i < 31; i++) {
		    total += base;
		    base *= 2;
		}
		long count = comb[31][x];
		long sum = total * comb[30][x - 1];
		System.out.println(count + " " + sum);
	}
}
0