結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー tentententen
提出日時 2023-11-21 13:09:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 161 ms / 3,000 ms
コード長 2,544 bytes
コンパイル時間 2,807 ms
コンパイル使用メモリ 88,776 KB
実行使用メモリ 60,636 KB
最終ジャッジ日時 2023-11-21 13:09:52
合計ジャッジ時間 6,391 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
54,008 KB
testcase_01 AC 53 ms
54,000 KB
testcase_02 AC 58 ms
53,984 KB
testcase_03 AC 55 ms
54,016 KB
testcase_04 AC 56 ms
53,988 KB
testcase_05 AC 53 ms
53,996 KB
testcase_06 AC 53 ms
53,984 KB
testcase_07 AC 53 ms
53,992 KB
testcase_08 AC 53 ms
53,992 KB
testcase_09 AC 53 ms
54,008 KB
testcase_10 AC 54 ms
53,996 KB
testcase_11 AC 53 ms
53,980 KB
testcase_12 AC 54 ms
54,004 KB
testcase_13 AC 55 ms
54,000 KB
testcase_14 AC 55 ms
54,000 KB
testcase_15 AC 55 ms
53,980 KB
testcase_16 AC 57 ms
53,988 KB
testcase_17 AC 56 ms
54,004 KB
testcase_18 AC 57 ms
53,984 KB
testcase_19 AC 57 ms
54,000 KB
testcase_20 AC 58 ms
54,000 KB
testcase_21 AC 58 ms
53,988 KB
testcase_22 AC 58 ms
53,976 KB
testcase_23 AC 58 ms
53,992 KB
testcase_24 AC 59 ms
53,996 KB
testcase_25 AC 58 ms
53,996 KB
testcase_26 AC 58 ms
53,996 KB
testcase_27 AC 58 ms
53,984 KB
testcase_28 AC 58 ms
54,004 KB
testcase_29 AC 60 ms
54,016 KB
testcase_30 AC 91 ms
55,040 KB
testcase_31 AC 83 ms
55,416 KB
testcase_32 AC 161 ms
55,944 KB
testcase_33 AC 102 ms
57,504 KB
testcase_34 AC 121 ms
60,196 KB
testcase_35 AC 127 ms
60,308 KB
testcase_36 AC 121 ms
60,200 KB
testcase_37 AC 149 ms
60,636 KB
testcase_38 AC 123 ms
60,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        char[] inputs = sc.next().toCharArray();
        int[][] dp = new int[inputs.length][100];
        for (int i = 1; i < inputs[0] - '0'; i++) {
            dp[0][i] = 1;
        }
        int base = inputs[0] - '0';
        boolean isZero = false;
        for (int i = 1; i < inputs.length; i++) {
            int x = inputs[i] - '0';
            for (int j = 0; j < 100; j++) {
                for (int k = 1; k < 10; k++) {
                    dp[i][(j * k) % 100] += dp[i - 1][j];
                    dp[i][(j * k) % 100] %= MOD;
                }
            }
            for (int j = 1; j < 10; j++) {
                dp[i][j]++;
            }
            if (isZero) {
                continue;
            }
            for (int j = 1; j < x; j++) {
                dp[i][(base * j) % 100]++;
            }
            if (x == 0) {
                isZero = true;
            }
            base *= x;
            base %= 100;
        }
        if (!isZero && base == 0) {
            dp[inputs.length - 1][0]++;
        }
        System.out.println(dp[inputs.length - 1][0]);
    }
}
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