結果

問題 No.189 SUPER HAPPY DAY
ユーザー tentententen
提出日時 2023-01-27 08:19:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 797 ms / 5,000 ms
コード長 2,625 bytes
コンパイル時間 2,814 ms
コンパイル使用メモリ 90,132 KB
実行使用メモリ 63,488 KB
最終ジャッジ日時 2023-09-10 05:03:03
合計ジャッジ時間 10,845 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,384 KB
testcase_01 AC 51 ms
50,948 KB
testcase_02 AC 45 ms
49,396 KB
testcase_03 AC 52 ms
51,220 KB
testcase_04 AC 50 ms
50,648 KB
testcase_05 AC 51 ms
50,192 KB
testcase_06 AC 50 ms
50,108 KB
testcase_07 AC 51 ms
50,844 KB
testcase_08 AC 50 ms
50,128 KB
testcase_09 AC 51 ms
51,048 KB
testcase_10 AC 52 ms
50,908 KB
testcase_11 AC 50 ms
51,060 KB
testcase_12 AC 53 ms
50,428 KB
testcase_13 AC 353 ms
59,844 KB
testcase_14 AC 458 ms
60,488 KB
testcase_15 AC 518 ms
60,636 KB
testcase_16 AC 742 ms
62,804 KB
testcase_17 AC 557 ms
58,736 KB
testcase_18 AC 484 ms
61,064 KB
testcase_19 AC 797 ms
63,488 KB
testcase_20 AC 239 ms
58,612 KB
testcase_21 AC 204 ms
58,540 KB
testcase_22 AC 84 ms
52,292 KB
testcase_23 AC 282 ms
58,276 KB
testcase_24 AC 294 ms
58,340 KB
testcase_25 AC 408 ms
60,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static final int MOD = 1000000009;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        HashMap<Integer, Long> month = getCount(sc.next().toCharArray());
        HashMap<Integer, Long> day = getCount(sc.next().toCharArray());
        long ans = 0;
        for (int x : month.keySet()) {
            if (x == 0) {
                continue;
            }
            ans += month.get(x) * day.getOrDefault(x, 0L) % MOD;
            ans %= MOD;
        }
        System.out.println(ans);
    }
    
    static HashMap<Integer, Long> getCount(char[] arr) {
        int base = 0;
        HashMap<Integer, Long> current = new HashMap<>();
        for (char c : arr) {
            HashMap<Integer, Long> next = new HashMap<>();
            int x = c - '0';
            for (int i = 0; i < x; i++) {
                next.put(base + i, (next.getOrDefault(base + i, 0L) + 1) % MOD);
            }
            for (int y : current.keySet()) {
                for (int i = 0; i < 10; i++) {
                    next.put(y + i, (next.getOrDefault(y + i, 0L) + current.get(y)) % MOD);
                }
            }
            base += x;
            current = next;
        }
        current.put(base, current.getOrDefault(base, 0L) + 1);
        return current;
    }
}

class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0