結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー tentententen
提出日時 2022-08-17 14:18:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 3,000 ms
コード長 2,175 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 77,628 KB
実行使用メモリ 57,740 KB
最終ジャッジ日時 2024-04-15 04:27:13
合計ジャッジ時間 6,248 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
50,432 KB
testcase_01 AC 53 ms
50,060 KB
testcase_02 AC 57 ms
50,408 KB
testcase_03 AC 52 ms
50,448 KB
testcase_04 AC 52 ms
50,392 KB
testcase_05 AC 51 ms
50,448 KB
testcase_06 AC 51 ms
50,072 KB
testcase_07 AC 52 ms
50,048 KB
testcase_08 AC 53 ms
50,484 KB
testcase_09 AC 52 ms
50,312 KB
testcase_10 AC 51 ms
50,036 KB
testcase_11 AC 53 ms
50,260 KB
testcase_12 AC 54 ms
50,416 KB
testcase_13 AC 55 ms
50,420 KB
testcase_14 AC 54 ms
50,364 KB
testcase_15 AC 55 ms
50,324 KB
testcase_16 AC 55 ms
50,444 KB
testcase_17 AC 54 ms
50,104 KB
testcase_18 AC 55 ms
50,436 KB
testcase_19 AC 55 ms
50,488 KB
testcase_20 AC 54 ms
50,068 KB
testcase_21 AC 55 ms
50,428 KB
testcase_22 AC 57 ms
50,136 KB
testcase_23 AC 57 ms
50,120 KB
testcase_24 AC 57 ms
50,372 KB
testcase_25 AC 57 ms
50,284 KB
testcase_26 AC 58 ms
50,504 KB
testcase_27 AC 58 ms
50,444 KB
testcase_28 AC 59 ms
50,416 KB
testcase_29 AC 57 ms
50,468 KB
testcase_30 AC 92 ms
51,868 KB
testcase_31 AC 90 ms
51,896 KB
testcase_32 AC 102 ms
52,328 KB
testcase_33 AC 112 ms
54,352 KB
testcase_34 AC 140 ms
57,740 KB
testcase_35 AC 133 ms
57,640 KB
testcase_36 AC 135 ms
57,172 KB
testcase_37 AC 153 ms
57,460 KB
testcase_38 AC 133 ms
56,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        char[] values = sc.next().toCharArray();
        int length = values.length;
        int[][] dp = new int[length + 1][100];
        int current = values[0] - '0';
        boolean isZero = false;
        for (int i = 1; i < values[0] - '0'; i++) {
            dp[1][i]++;
        }
        for (int i = 1; i < length; i++) {
            int v = values[i] - '0';
            for (int j = 0; j < 100; j++) {
                if (dp[i][j] == 0) {
                    continue;
                }
                for (int k = 1; k <= 9; k++) {
                    dp[i + 1][j * k % 100] += dp[i][j];
                    dp[i + 1][j * k % 100] %= MOD;
                }
            }
            if (!isZero) {
                for (int j = 1; j < v; j++) {
                    dp[i + 1][current * j % 100]++;
                    dp[i + 1][current * j % 100] %= MOD;
                }
                isZero = (v == 0);
                current *= v;
                current %= 100;
            }
            for (int j = 1; j <= 9; j++) {
                dp[i + 1][j]++;
                dp[i + 1][j] %= MOD;
            }
        }
        if (!isZero) {
            dp[length][current]++;
            dp[length][current] %= MOD;
        }
        System.out.println(dp[length][0]);
    }
}

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 {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0