結果
| 問題 |
No.189 SUPER HAPPY DAY
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-12-02 19:03:03 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 108 ms / 5,000 ms |
| コード長 | 1,863 bytes |
| コンパイル時間 | 2,229 ms |
| コンパイル使用メモリ | 77,556 KB |
| 実行使用メモリ | 42,080 KB |
| 最終ジャッジ日時 | 2024-07-05 02:00:56 |
| 合計ジャッジ時間 | 4,903 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
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();
}
}
tenten