結果

問題 No.287 場合の数
ユーザー uafr_csuafr_cs
提出日時 2015-10-12 00:16:20
言語 Java19
(openjdk 21)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 869 bytes
コンパイル時間 1,824 ms
コンパイル使用メモリ 71,788 KB
実行使用メモリ 56,472 KB
最終ジャッジ日時 2023-08-07 18:59:36
合計ジャッジ時間 6,078 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
56,272 KB
testcase_01 AC 118 ms
55,768 KB
testcase_02 AC 120 ms
56,164 KB
testcase_03 AC 131 ms
56,324 KB
testcase_04 AC 131 ms
56,016 KB
testcase_05 AC 132 ms
56,296 KB
testcase_06 AC 119 ms
56,016 KB
testcase_07 AC 122 ms
55,812 KB
testcase_08 AC 129 ms
55,792 KB
testcase_09 AC 134 ms
55,668 KB
testcase_10 AC 132 ms
56,040 KB
testcase_11 AC 121 ms
56,136 KB
testcase_12 AC 130 ms
56,472 KB
testcase_13 AC 120 ms
55,916 KB
testcase_14 AC 124 ms
55,524 KB
testcase_15 AC 130 ms
55,808 KB
testcase_16 AC 125 ms
56,012 KB
testcase_17 AC 132 ms
56,424 KB
testcase_18 AC 121 ms
55,904 KB
testcase_19 AC 131 ms
55,780 KB
testcase_20 AC 126 ms
56,292 KB
testcase_21 AC 132 ms
55,944 KB
testcase_22 AC 130 ms
55,636 KB
testcase_23 AC 126 ms
56,040 KB
testcase_24 AC 125 ms
56,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		final int dp_size = 6 * n;
		long[] DP = new long[dp_size + 1];
		for(int i = 0; i <= n; i++){
			DP[i] = 1;
		}
		
		for(int tt = 0; tt < 3; tt++){
			long[] next_DP = new long[dp_size + 1];
			
			for(int fst = 0; fst <= dp_size; fst++){
				if(DP[fst] == 0){ continue; }
				
				for(int snd = 0; snd <= dp_size - fst; snd++){
					if(DP[snd] == 0){ continue; }
					
					next_DP[fst + snd] += DP[fst] * DP[snd];
				}
			}
			
			//System.out.println(Arrays.toString(DP));
			//System.out.println(Arrays.toString(next_DP));
			
			DP = next_DP;
		}
		
		System.out.println(DP[dp_size]);
		
	}

}
0