結果
問題 | No.372 It's automatic |
ユーザー | tenten |
提出日時 | 2021-12-03 14:47:55 |
言語 | Java21 (openjdk 21) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,680 bytes |
コンパイル時間 | 2,669 ms |
コンパイル使用メモリ | 74,540 KB |
実行使用メモリ | 741,344 KB |
最終ジャッジ日時 | 2023-09-19 06:39:28 |
合計ジャッジ時間 | 18,512 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
49,316 KB |
testcase_01 | AC | 43 ms
49,340 KB |
testcase_02 | AC | 43 ms
49,316 KB |
testcase_03 | AC | 43 ms
49,292 KB |
testcase_04 | MLE | - |
testcase_05 | MLE | - |
testcase_06 | MLE | - |
testcase_07 | MLE | - |
testcase_08 | MLE | - |
testcase_09 | MLE | - |
testcase_10 | MLE | - |
testcase_11 | MLE | - |
testcase_12 | MLE | - |
testcase_13 | MLE | - |
testcase_14 | MLE | - |
testcase_15 | MLE | - |
testcase_16 | AC | 46 ms
49,280 KB |
testcase_17 | AC | 45 ms
49,468 KB |
testcase_18 | AC | 44 ms
49,516 KB |
testcase_19 | AC | 44 ms
49,356 KB |
testcase_20 | AC | 44 ms
49,360 KB |
testcase_21 | AC | 228 ms
90,244 KB |
testcase_22 | AC | 220 ms
89,188 KB |
testcase_23 | AC | 204 ms
90,176 KB |
testcase_24 | AC | 193 ms
89,884 KB |
testcase_25 | AC | 192 ms
89,400 KB |
ソースコード
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 k = sc.nextInt(); int length = values.length; int[][] dp = new int[length][k]; int ans = 0; for (int i = 0; i < length; i++) { int x = values[i] - '0'; for (int j = 0; j < k && i > 0; j++) { if (dp[i - 1][j] > 0) { dp[i][(j * 10 + x) % k] += dp[i - 1][j]; dp[i][(j * 10 + x) % k] %= MOD; dp[i][j] += dp[i - 1][j]; dp[i][j] %= MOD; } } if (x == 0) { ans++; ans %= MOD; } else { dp[i][x % k]++; } } System.out.println((ans + dp[length - 1][0]) % MOD); } } 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 { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }