結果
問題 | No.1407 Kindness |
ユーザー |
![]() |
提出日時 | 2023-01-12 10:47:20 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,815 bytes |
コンパイル時間 | 2,351 ms |
コンパイル使用メモリ | 85,488 KB |
実行使用メモリ | 129,768 KB |
最終ジャッジ日時 | 2024-06-02 08:45:40 |
合計ジャッジ時間 | 8,127 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
42,092 KB |
testcase_01 | AC | 595 ms
60,240 KB |
testcase_02 | AC | 54 ms
37,444 KB |
testcase_03 | AC | 50 ms
36,868 KB |
testcase_04 | AC | 76 ms
38,608 KB |
testcase_05 | AC | 57 ms
37,060 KB |
testcase_06 | AC | 58 ms
37,292 KB |
testcase_07 | AC | 73 ms
38,228 KB |
testcase_08 | AC | 78 ms
38,552 KB |
testcase_09 | AC | 75 ms
38,172 KB |
testcase_10 | AC | 78 ms
38,428 KB |
testcase_11 | AC | 72 ms
38,028 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
ソースコード
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; HashMap<Long, Integer> current = new HashMap<>(); HashMap<Long, Integer> next = new HashMap<>(); long base = inputs[0] - '0'; for (long i = 1; i < base; i++) { current.put(i, 1); } for (int i = 1; i < length; i++) { for (long x : current.keySet()) { for (int j = 1; j <= 9; j++) { long key = x * j % MOD; next.put(key, (next.getOrDefault(key, 0) + current.get(x)) % MOD); } } for (long j = 1; j < 10; j++) { next.put(j, (next.getOrDefault(j, 0) + 1) % MOD); } if (base > 0) { for (int j = 1; j < inputs[i] - '0'; j++) { long key = base * j % MOD; next.put(key, (next.getOrDefault(key, 0) + 1) % MOD); } } base *= inputs[i] - '0'; base %= MOD; HashMap<Long, Integer> tmp = current; current = next; next = tmp; next.clear(); } long ans = base; for (long x : current.keySet()) { ans += x * current.get(x) % MOD; ans %= MOD; } System.out.println(ans); } } 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(); } }