結果

問題 No.220 世界のなんとか2
ユーザー ぴろずぴろず
提出日時 2015-05-29 22:48:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 1,000 ms
コード長 551 bytes
コンパイル時間 2,740 ms
コンパイル使用メモリ 71,916 KB
実行使用メモリ 56,236 KB
最終ジャッジ日時 2023-09-20 16:43:49
合計ジャッジ時間 6,057 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,448 KB
testcase_01 AC 121 ms
55,704 KB
testcase_02 AC 121 ms
55,920 KB
testcase_03 AC 121 ms
55,252 KB
testcase_04 AC 123 ms
55,528 KB
testcase_05 AC 122 ms
55,648 KB
testcase_06 AC 123 ms
55,940 KB
testcase_07 AC 125 ms
55,720 KB
testcase_08 AC 122 ms
56,236 KB
testcase_09 AC 121 ms
55,424 KB
testcase_10 AC 121 ms
55,848 KB
testcase_11 AC 121 ms
56,028 KB
testcase_12 AC 121 ms
55,852 KB
testcase_13 AC 122 ms
55,732 KB
testcase_14 AC 122 ms
55,672 KB
testcase_15 AC 121 ms
55,476 KB
testcase_16 AC 121 ms
55,572 KB
testcase_17 AC 120 ms
55,944 KB
testcase_18 AC 125 ms
55,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no220;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		long[][] dp = new long[p+1][4];
		dp[0][1] = 1;
		for(int i=0;i<p;i++) {
			for(int j=0;j<3;j++) {
				for(int k=0;k<=9;k++) {
					if (k == 3) {
						dp[i+1][3] += dp[i][j];
					}else{
						dp[i+1][(j+k)%3] += dp[i][j];
					}
				}
			}
			dp[i+1][3] += dp[i][3] * 10;
		}
//		System.out.println(Arrays.deepToString(dp));
		System.out.println(dp[p][0] + dp[p][3] - 1);
	}

}
0