結果

問題 No.420 mod2漸化式
ユーザー htensai
提出日時 2019-11-20 00:54:57
言語 Java
(openjdk 23)
結果
AC  
実行時間 152 ms / 1,000 ms
コード長 801 bytes
コンパイル時間 2,619 ms
コンパイル使用メモリ 79,120 KB
実行使用メモリ 55,060 KB
最終ジャッジ日時 2024-10-04 16:52:43
合計ジャッジ時間 8,422 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

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