結果
問題 | No.2032 Let's Write Multiples!! |
ユーザー | Shirotsume |
提出日時 | 2022-07-15 00:37:59 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,130 bytes |
コンパイル時間 | 230 ms |
コンパイル使用メモリ | 11,108 KB |
実行使用メモリ | 8,888 KB |
最終ジャッジ日時 | 2023-09-08 16:49:23 |
合計ジャッジ時間 | 18,754 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
8,776 KB |
testcase_01 | TLE | - |
testcase_02 | AC | 2,698 ms
8,620 KB |
testcase_03 | AC | 2,688 ms
8,640 KB |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
ソースコード
from functools import lru_cache import sys ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) INF = 2 ** 63 - 1 mod = 998244353 def floor_sum(N, M, a, b): res = 0 while N: q, a = divmod(a, M) res += N * (N - 1) // 2 * q q, b = divmod(b, M) res += N * q N, b = divmod(a * N + b, M) a, M = M, a return res def f(r, k, c): n = r // k ans = 0 for i in range(1, 10): d = 10 ** i x = c * (d // 10) y = (c + 1) * (d // 10) ans += n - floor_sum(n, d, k, d + k) + floor_sum(n, d, k, d + k - x) if c < 9: ans -= n - floor_sum(n, d, k, d + k) + floor_sum(n, d, k, d + k - y) return ans def solve(l, r, k, c): return f(r, k, c) - f(l - 1, k, c) def solve_gu(l, r, k, c): s = (l + k - 1) // k t = r // k ans = 0 for i in range(s, t + 1): now = k * i while now > 0: if now % 10 == c: ans += 1 now //= 10 return ans for _ in range(ii()): l, r, k, c = mi() print(solve(l, r, k, c))