結果

問題 No.189 SUPER HAPPY DAY
ユーザー tentententen
提出日時 2020-12-29 01:49:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 163 ms / 5,000 ms
コード長 886 bytes
コンパイル時間 1,871 ms
コンパイル使用メモリ 77,984 KB
実行使用メモリ 41,500 KB
最終ジャッジ日時 2024-04-15 01:24:01
合計ジャッジ時間 6,477 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
41,132 KB
testcase_01 AC 135 ms
41,164 KB
testcase_02 AC 119 ms
41,264 KB
testcase_03 AC 139 ms
41,072 KB
testcase_04 AC 137 ms
40,912 KB
testcase_05 AC 133 ms
40,948 KB
testcase_06 AC 133 ms
40,768 KB
testcase_07 AC 137 ms
41,104 KB
testcase_08 AC 139 ms
41,388 KB
testcase_09 AC 132 ms
41,200 KB
testcase_10 AC 132 ms
41,140 KB
testcase_11 AC 137 ms
40,932 KB
testcase_12 AC 134 ms
41,304 KB
testcase_13 AC 134 ms
41,348 KB
testcase_14 AC 152 ms
40,960 KB
testcase_15 AC 152 ms
41,184 KB
testcase_16 AC 155 ms
41,464 KB
testcase_17 AC 163 ms
41,500 KB
testcase_18 AC 160 ms
41,248 KB
testcase_19 AC 148 ms
41,344 KB
testcase_20 AC 152 ms
41,292 KB
testcase_21 AC 157 ms
41,392 KB
testcase_22 AC 131 ms
41,120 KB
testcase_23 AC 118 ms
40,736 KB
testcase_24 AC 145 ms
40,932 KB
testcase_25 AC 157 ms
40,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000009;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] mdp = getDP(sc.next().toCharArray());
		int[] ddp = getDP(sc.next().toCharArray());
		long ans = 0;
		for (int i = 1; i < 2000; i++) {
		    ans += (long)mdp[i] * ddp[i] % MOD;
		    ans %= MOD;
		}
		System.out.println(ans);
	}
	
	static int[] getDP(char[] arr) {
	    int[] dp = new int[2000];
	    int sum = 0;
	    for (int i = 0; i < arr.length; i++) {
	        for (int j = dp.length - 10; j >= 0; j--) {
	            for (int k = 1; k < 10; k++) {
	                dp[j + k] += dp[j];
	                dp[j + k] %= MOD;
	            }
	        }
	        for (int j = 0; j < arr[i] - '0'; j++) {
	            dp[sum + j]++;
	        }
	        sum += arr[i] - '0';
	    }
	    dp[sum]++;
	    return dp;
	}
}
0