結果
問題 | No.372 It's automatic |
ユーザー | tenten |
提出日時 | 2023-12-14 08:27:54 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,957 ms / 6,000 ms |
コード長 | 2,264 bytes |
コンパイル時間 | 2,664 ms |
コンパイル使用メモリ | 90,144 KB |
実行使用メモリ | 56,368 KB |
最終ジャッジ日時 | 2023-12-14 08:28:24 |
合計ジャッジ時間 | 28,734 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
54,000 KB |
testcase_01 | AC | 56 ms
54,008 KB |
testcase_02 | AC | 53 ms
53,964 KB |
testcase_03 | AC | 54 ms
54,052 KB |
testcase_04 | AC | 1,918 ms
56,356 KB |
testcase_05 | AC | 1,945 ms
56,308 KB |
testcase_06 | AC | 1,914 ms
56,324 KB |
testcase_07 | AC | 1,946 ms
56,352 KB |
testcase_08 | AC | 1,927 ms
56,308 KB |
testcase_09 | AC | 1,930 ms
56,324 KB |
testcase_10 | AC | 1,924 ms
56,368 KB |
testcase_11 | AC | 1,901 ms
56,304 KB |
testcase_12 | AC | 1,920 ms
56,316 KB |
testcase_13 | AC | 1,911 ms
54,364 KB |
testcase_14 | AC | 1,907 ms
56,340 KB |
testcase_15 | AC | 1,957 ms
56,364 KB |
testcase_16 | AC | 55 ms
54,028 KB |
testcase_17 | AC | 55 ms
54,020 KB |
testcase_18 | AC | 56 ms
53,992 KB |
testcase_19 | AC | 54 ms
54,016 KB |
testcase_20 | AC | 55 ms
54,000 KB |
testcase_21 | AC | 200 ms
56,264 KB |
testcase_22 | AC | 191 ms
56,248 KB |
testcase_23 | AC | 191 ms
56,256 KB |
testcase_24 | AC | 192 ms
56,260 KB |
testcase_25 | AC | 195 ms
56,260 KB |
ソースコード
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 length = inputs.length; int m = sc.nextInt(); int[] current = new int[m]; int[] next = new int[m]; int ans = 0; for (int i = 0; i < length; i++) { int x = inputs[i] - '0'; for (int j = 0; j < m; j++) { next[j] += current[j]; next[j] %= MOD; next[(j * 10 + x) % m] += current[j]; next[(j * 10 + x) % m] %= MOD; } if (x == 0) { ans++; } else { next[x % m]++; } int[] tmp = next; next = current; current = tmp; Arrays.fill(next, 0); } System.out.println((current[0] + ans) % MOD); } } 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(); } }