結果
問題 | No.189 SUPER HAPPY DAY |
ユーザー | tenten |
提出日時 | 2023-06-13 09:30:37 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 97 ms / 5,000 ms |
コード長 | 2,493 bytes |
コンパイル時間 | 5,108 ms |
コンパイル使用メモリ | 86,148 KB |
実行使用メモリ | 54,504 KB |
最終ジャッジ日時 | 2023-09-03 15:54:39 |
合計ジャッジ時間 | 6,771 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
49,748 KB |
testcase_01 | AC | 43 ms
49,420 KB |
testcase_02 | AC | 42 ms
49,272 KB |
testcase_03 | AC | 43 ms
49,356 KB |
testcase_04 | AC | 43 ms
49,420 KB |
testcase_05 | AC | 42 ms
49,420 KB |
testcase_06 | AC | 42 ms
49,472 KB |
testcase_07 | AC | 42 ms
49,296 KB |
testcase_08 | AC | 42 ms
49,540 KB |
testcase_09 | AC | 41 ms
49,368 KB |
testcase_10 | AC | 41 ms
49,376 KB |
testcase_11 | AC | 41 ms
49,388 KB |
testcase_12 | AC | 42 ms
49,320 KB |
testcase_13 | AC | 78 ms
50,384 KB |
testcase_14 | AC | 91 ms
53,476 KB |
testcase_15 | AC | 78 ms
53,452 KB |
testcase_16 | AC | 77 ms
53,456 KB |
testcase_17 | AC | 97 ms
53,924 KB |
testcase_18 | AC | 75 ms
53,552 KB |
testcase_19 | AC | 93 ms
53,684 KB |
testcase_20 | AC | 82 ms
51,580 KB |
testcase_21 | AC | 69 ms
51,608 KB |
testcase_22 | AC | 43 ms
49,344 KB |
testcase_23 | AC | 77 ms
53,888 KB |
testcase_24 | AC | 94 ms
54,160 KB |
testcase_25 | AC | 96 ms
54,504 KB |
ソースコード
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(); long[] months = getCount(sc.next().toCharArray()); long[] days = getCount(sc.next().toCharArray()); long ans = 0; for (int i = 1; i < months.length && i < days.length; i++) { ans += months[i] * days[i] % MOD; ans %= MOD; } System.out.println(ans); } static long[] getCount(char[] inputs) { int length = inputs.length; long[][] dp = new long[length + 1][length * 9 + 1]; int current = 0; for (int i = 1; i <= length; i++) { int x = inputs[i - 1] - '0'; for (int j = 0; j <= (i - 1) * 9; 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 < x; j++) { dp[i][current + j]++; dp[i][current + j] %= MOD; } current += x; } dp[length][current]++; return dp[length]; } } 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(); } }