結果

問題 No.1085 桁和の桁和
ユーザー tentententen
提出日時 2020-08-19 09:09:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 896 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 74,360 KB
実行使用メモリ 48,500 KB
最終ジャッジ日時 2024-04-24 10:13:56
合計ジャッジ時間 10,409 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
41,088 KB
testcase_01 AC 112 ms
41,416 KB
testcase_02 AC 112 ms
41,404 KB
testcase_03 AC 114 ms
41,400 KB
testcase_04 AC 251 ms
47,876 KB
testcase_05 AC 123 ms
40,968 KB
testcase_06 AC 114 ms
40,276 KB
testcase_07 AC 114 ms
41,296 KB
testcase_08 AC 113 ms
41,156 KB
testcase_09 AC 112 ms
41,280 KB
testcase_10 AC 114 ms
41,356 KB
testcase_11 AC 119 ms
41,348 KB
testcase_12 AC 120 ms
41,192 KB
testcase_13 AC 135 ms
41,068 KB
testcase_14 AC 165 ms
43,900 KB
testcase_15 AC 227 ms
48,104 KB
testcase_16 AC 228 ms
48,292 KB
testcase_17 AC 175 ms
43,860 KB
testcase_18 AC 139 ms
41,960 KB
testcase_19 AC 236 ms
48,020 KB
testcase_20 AC 210 ms
47,716 KB
testcase_21 AC 191 ms
47,796 KB
testcase_22 AC 227 ms
47,616 KB
testcase_23 AC 153 ms
42,056 KB
testcase_24 AC 120 ms
41,312 KB
testcase_25 AC 179 ms
44,756 KB
testcase_26 AC 223 ms
48,140 KB
testcase_27 AC 221 ms
47,744 KB
testcase_28 AC 227 ms
48,024 KB
testcase_29 AC 194 ms
47,956 KB
testcase_30 AC 194 ms
48,500 KB
testcase_31 AC 227 ms
48,080 KB
testcase_32 AC 205 ms
48,188 KB
testcase_33 AC 240 ms
47,912 KB
testcase_34 AC 244 ms
48,204 KB
testcase_35 AC 246 ms
48,068 KB
testcase_36 AC 238 ms
48,392 KB
testcase_37 AC 229 ms
47,968 KB
testcase_38 AC 231 ms
47,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        int d = sc.nextInt();
        int[][] dp = new int[arr.length + 1][10];
        dp[0][0] = 1;
        for (int i = 1; i <= arr.length; i++) {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 10; k++) {
                    if (arr[i - 1] == '?' || arr[i - 1] - '0' == k) {
                        int idx = j + k;
                        if (idx >= 10) {
                            idx = idx % 10 + 1;
                        }
                        dp[i][idx] += dp[i - 1][j];
                        dp[i][idx] %= MOD;
                    }
                }
            }
        }
        System.out.println(dp[arr.length][d]);
    }
} 
0