結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー tentententen
提出日時 2021-03-11 10:56:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 3,000 ms
コード長 1,276 bytes
コンパイル時間 2,896 ms
コンパイル使用メモリ 77,248 KB
実行使用メモリ 43,160 KB
最終ジャッジ日時 2024-04-21 02:14:05
合計ジャッジ時間 10,571 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
40,968 KB
testcase_01 AC 105 ms
40,076 KB
testcase_02 AC 120 ms
41,092 KB
testcase_03 AC 114 ms
41,120 KB
testcase_04 AC 103 ms
40,308 KB
testcase_05 AC 105 ms
40,072 KB
testcase_06 AC 102 ms
40,160 KB
testcase_07 AC 106 ms
40,408 KB
testcase_08 AC 106 ms
40,396 KB
testcase_09 AC 110 ms
40,232 KB
testcase_10 AC 121 ms
41,588 KB
testcase_11 AC 113 ms
40,388 KB
testcase_12 AC 117 ms
41,512 KB
testcase_13 AC 102 ms
40,076 KB
testcase_14 AC 116 ms
41,280 KB
testcase_15 AC 116 ms
41,092 KB
testcase_16 AC 109 ms
39,872 KB
testcase_17 AC 116 ms
40,636 KB
testcase_18 AC 120 ms
41,264 KB
testcase_19 AC 110 ms
40,200 KB
testcase_20 AC 107 ms
39,952 KB
testcase_21 AC 115 ms
40,648 KB
testcase_22 AC 121 ms
41,216 KB
testcase_23 AC 117 ms
41,384 KB
testcase_24 AC 117 ms
41,176 KB
testcase_25 AC 121 ms
41,012 KB
testcase_26 AC 125 ms
41,172 KB
testcase_27 AC 108 ms
40,376 KB
testcase_28 AC 108 ms
40,300 KB
testcase_29 AC 108 ms
40,072 KB
testcase_30 AC 129 ms
41,020 KB
testcase_31 AC 118 ms
40,304 KB
testcase_32 AC 158 ms
42,668 KB
testcase_33 AC 176 ms
42,404 KB
testcase_34 AC 190 ms
42,888 KB
testcase_35 AC 198 ms
43,160 KB
testcase_36 AC 181 ms
43,012 KB
testcase_37 AC 183 ms
43,108 KB
testcase_38 AC 188 ms
42,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static int[] next = new int[]{0, 1, 2, 4, 5, 10, 20, 25, 50, 100};
	static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int length = arr.length;
		int size = next.length;
		int[][] dp = new int[length][size];
		for (int i = 1; i < arr[0] - '0'; i++) {
		    dp[0][getNum(i)]++;
		}
		int base = getNum(arr[0] - '0');
		for (int i = 1; i < length; i++) {
		    int x = arr[i] - '0';
		    for (int j = 1; j < x; j++) {
		        dp[i][getNum(next[base] * j)]++;
		    }
		    for (int j = 1; j < 10; j++) {
		        dp[i][getNum(j)]++;
		    }
		    base = getNum(next[base] * x);
		    for (int j = 1; j < size; j++) {
		        for (int k = 1; k < 10; k++) {
		            int idx = getNum(next[j] * k);
		            dp[i][idx] += dp[i - 1][j];
		            dp[i][idx] %= MOD;
		        }
		    }
		}
		dp[length - 1][base]++;
		System.out.println(dp[length - 1][size - 1]);
   }
   
   static int getNum(int x) {
       if (x == 0) {
           return 0;
       }
       for (int i = next.length - 1; i > 0; i--) {
           if (x % next[i] == 0) {
               return i;
           }
       }
       return 0;
   }
}

0