結果

問題 No.189 SUPER HAPPY DAY
ユーザー tentententen
提出日時 2021-12-02 19:03:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 93 ms / 5,000 ms
コード長 1,863 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 75,080 KB
実行使用メモリ 54,132 KB
最終ジャッジ日時 2023-09-18 10:25:43
合計ジャッジ時間 4,567 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,212 KB
testcase_01 AC 42 ms
49,428 KB
testcase_02 AC 43 ms
49,288 KB
testcase_03 AC 42 ms
49,428 KB
testcase_04 AC 42 ms
49,416 KB
testcase_05 AC 43 ms
49,560 KB
testcase_06 AC 43 ms
49,344 KB
testcase_07 AC 44 ms
49,380 KB
testcase_08 AC 42 ms
49,340 KB
testcase_09 AC 42 ms
49,428 KB
testcase_10 AC 41 ms
49,228 KB
testcase_11 AC 42 ms
49,300 KB
testcase_12 AC 42 ms
49,376 KB
testcase_13 AC 68 ms
51,488 KB
testcase_14 AC 83 ms
51,728 KB
testcase_15 AC 72 ms
51,692 KB
testcase_16 AC 72 ms
51,576 KB
testcase_17 AC 83 ms
51,512 KB
testcase_18 AC 68 ms
51,516 KB
testcase_19 AC 93 ms
53,684 KB
testcase_20 AC 70 ms
48,988 KB
testcase_21 AC 70 ms
51,556 KB
testcase_22 AC 44 ms
49,676 KB
testcase_23 AC 69 ms
51,532 KB
testcase_24 AC 69 ms
51,504 KB
testcase_25 AC 93 ms
54,132 KB
権限があれば一括ダウンロードができます

ソースコード

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];
                    dp[i][j + k] %= MOD;
                }
            }
            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