結果

問題 No.420 mod2漸化式
ユーザー hermione17
提出日時 2016-09-09 22:48:38
言語 Java
(openjdk 23)
結果
AC  
実行時間 181 ms / 1,000 ms
コード長 645 bytes
コンパイル時間 4,530 ms
コンパイル使用メモリ 76,376 KB
実行使用メモリ 42,432 KB
最終ジャッジ日時 2024-12-24 11:04:03
合計ジャッジ時間 11,858 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Y420 {
	Y420() {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		
		long ansCnt = 0, ansSum = 0;
	
		if (1 <= x && x <= 31) {
			long comb = 1;
			ansCnt = 1;
			for (int i = 0; i < x; i++) {
				ansCnt = ansCnt * (31 - i) / (i + 1);
			}
			for (int i = 0; i < x - 1; i++) {
				comb = comb * (30 - i) / (i + 1);
			}
			
			long power = 1;
			for (int i = 0; i < 31; i++) {
				ansSum += comb * power;
				power *= 2;
			}
		} else if (x == 0) {
			ansCnt = 1;
		}
		
		System.out.println("" + ansCnt + " " + ansSum);
	}
	public static void main(String argv[]) {
		new Y420();
	}
}
0