結果

問題 No.189 SUPER HAPPY DAY
ユーザー ぴろずぴろず
提出日時 2015-05-29 11:58:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,156 bytes
コンパイル時間 3,956 ms
コンパイル使用メモリ 74,020 KB
実行使用メモリ 65,808 KB
最終ジャッジ日時 2023-09-20 15:33:15
合計ジャッジ時間 9,863 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,368 KB
testcase_01 AC 172 ms
56,696 KB
testcase_02 AC 122 ms
55,380 KB
testcase_03 AC 163 ms
56,820 KB
testcase_04 AC 163 ms
56,360 KB
testcase_05 AC 159 ms
56,216 KB
testcase_06 AC 160 ms
56,092 KB
testcase_07 AC 166 ms
56,368 KB
testcase_08 AC 164 ms
56,320 KB
testcase_09 AC 164 ms
56,500 KB
testcase_10 AC 163 ms
56,428 KB
testcase_11 AC 164 ms
56,688 KB
testcase_12 AC 165 ms
56,676 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 210 ms
65,520 KB
testcase_17 WA -
testcase_18 AC 203 ms
61,144 KB
testcase_19 WA -
testcase_20 AC 192 ms
60,932 KB
testcase_21 WA -
testcase_22 AC 174 ms
58,648 KB
testcase_23 AC 180 ms
60,404 KB
testcase_24 AC 203 ms
60,908 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package no189;

import java.util.Scanner;

public class Main {
	public static final long MOD = 1000000009;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long[] m = count(sc.next());
		long[] d = count(sc.next());
		long ans = 0;
		for(int i=1;i<=2000;i++) {
			ans = (ans + m[i] * d[i]) % MOD;
		}
		System.out.println(ans);
	}

	public static long[] count(String s) {
		int n = s.length();
		int[] d = new int[n];
		for(int i=0;i<n;i++) {
			d[i] = s.charAt(i) - '0';
		}
		long[][][] dp = new long[n+1][2][2020];
		dp[0][0][0] = 1;
		for(int i=0;i<n;i++) {
			for(int j=0;j<=2000;j++) {
				for(int k=0;k<=9;k++) {
					dp[i+1][1][j+k] += dp[i][1][j];
					if (d[i] > k) {
						dp[i+1][1][j+k] += dp[i][0][j];
					}else if(d[i] == k) {
						dp[i+1][0][j+k] += dp[i][0][j];
					}
					dp[i+1][0][j+k] %= MOD;
					dp[i+1][1][j+k] %= MOD;
				}
			}
//			System.out.println(i);
//			System.out.println(Arrays.toString(dp[i][0]));
//			System.out.println(Arrays.toString(dp[i][1]));
		}
		long[] ret = new long[2020];
		for(int i=0;i<202;i++) {
			ret[i] = (dp[n][0][i] + dp[n][1][i]) % MOD;
		}
		return ret;
	}

}
0