結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー tentententen
提出日時 2021-03-11 10:34:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,250 bytes
コンパイル時間 3,531 ms
コンパイル使用メモリ 77,412 KB
実行使用メモリ 55,940 KB
最終ジャッジ日時 2024-04-21 01:59:02
合計ジャッジ時間 9,776 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
54,056 KB
testcase_01 AC 130 ms
54,096 KB
testcase_02 AC 132 ms
54,216 KB
testcase_03 AC 127 ms
54,160 KB
testcase_04 AC 127 ms
54,020 KB
testcase_05 AC 125 ms
53,864 KB
testcase_06 WA -
testcase_07 AC 126 ms
54,076 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 118 ms
54,812 KB
testcase_11 AC 125 ms
53,900 KB
testcase_12 AC 127 ms
53,992 KB
testcase_13 AC 128 ms
54,068 KB
testcase_14 AC 126 ms
54,028 KB
testcase_15 AC 130 ms
53,760 KB
testcase_16 WA -
testcase_17 AC 131 ms
54,092 KB
testcase_18 AC 130 ms
54,208 KB
testcase_19 AC 131 ms
54,176 KB
testcase_20 AC 134 ms
54,252 KB
testcase_21 AC 130 ms
53,956 KB
testcase_22 AC 131 ms
54,144 KB
testcase_23 WA -
testcase_24 AC 117 ms
52,872 KB
testcase_25 WA -
testcase_26 AC 130 ms
54,164 KB
testcase_27 AC 131 ms
54,032 KB
testcase_28 WA -
testcase_29 AC 131 ms
53,896 KB
testcase_30 AC 141 ms
54,152 KB
testcase_31 AC 141 ms
54,464 KB
testcase_32 AC 177 ms
55,040 KB
testcase_33 AC 182 ms
54,820 KB
testcase_34 AC 212 ms
55,372 KB
testcase_35 AC 232 ms
54,976 KB
testcase_36 AC 195 ms
54,988 KB
testcase_37 AC 226 ms
55,568 KB
testcase_38 AC 201 ms
54,416 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;
		        }
		    }
		}
		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