結果

問題 No.189 SUPER HAPPY DAY
ユーザー tentententen
提出日時 2021-12-02 19:01:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,822 bytes
コンパイル時間 2,010 ms
コンパイル使用メモリ 74,188 KB
実行使用メモリ 54,704 KB
最終ジャッジ日時 2023-09-18 10:25:28
合計ジャッジ時間 4,745 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,672 KB
testcase_01 AC 42 ms
49,216 KB
testcase_02 AC 41 ms
49,488 KB
testcase_03 AC 41 ms
49,340 KB
testcase_04 AC 40 ms
49,380 KB
testcase_05 AC 42 ms
49,356 KB
testcase_06 AC 42 ms
49,376 KB
testcase_07 AC 42 ms
49,224 KB
testcase_08 AC 41 ms
49,236 KB
testcase_09 AC 42 ms
49,408 KB
testcase_10 AC 43 ms
49,428 KB
testcase_11 AC 43 ms
49,372 KB
testcase_12 AC 43 ms
49,672 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 73 ms
51,492 KB
testcase_24 AC 68 ms
51,332 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    static final int MOD = 1000000009;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int[] month = getCounts(sc.next().toCharArray());
        int[] day = getCounts(sc.next().toCharArray());
        long ans = 0;
        for (int i = 1; i < month.length && i < day.length; i++) {
            ans += (long)month[i] * day[i] % MOD;
            ans %= MOD;
        }
        System.out.println(ans);
    }
    
    static int[] getCounts(char[] arr) {
        int length = arr.length;
        int[][] dp = new int[length][length * 10 + 10];
        int count = 0;
        for (int i = 0; i < length; i++) {
            for (int j = i * 10 - i - 1; j >= 0 && i > 0; j--) {
                for (int k = 0; k < 10; k++) {
                    dp[i][j + k] += dp[i - 1][j];
                }
            }
            for (int j = 0; j < arr[i] - '0'; j++) {
                dp[i][count + j]++;
            }
            count += arr[i] - '0';
        }
        dp[length - 1][count]++;
        return dp[length - 1];
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0