結果
| 問題 | No.8133 Reversed |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-01 21:51:34 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,465 bytes |
| 記録 | |
| コンパイル時間 | 1,169 ms |
| コンパイル使用メモリ | 85,404 KB |
| 実行使用メモリ | 168,884 KB |
| 最終ジャッジ日時 | 2026-04-01 21:52:10 |
| 合計ジャッジ時間 | 10,950 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 5 TLE * 1 |
ソースコード
mod = 7000000001
p = [pow(10, i, mod) for i in range(40)]
def calc(x):
# print(x)
if x <= 0:
return 0
s = str(x)
n = len(s)
ans = 0
for l in range(1, n):
ans += 45 * p[l - 1] % mod
if l > 1:
ans += 45 * p[l - 2] * (p[l] - 10) % mod
dpc = [0, 0]
dps = [0, 0]
for i in range(n):
ndpc = [0, 0]
ndps = [0, 0]
lim = int(s[i])
if i == 0:
for d in range(1, lim + 1):
sm = int(d < lim)
ndpc[sm] += 1
ndps[sm] += d
else:
for sm in range(2):
if dpc[sm] == 0:
continue
limd = 9 if sm else lim
for d in range(limd + 1):
nsm = sm | int(d < limd)
ndpc[nsm] += dpc[sm] % mod
ndps[nsm] += dps[sm] + d * p[i] * dpc[sm] % mod
dpc = ndpc
dps = ndps
# print(ans + sum(dps))
return ans + sum(dps)
# print(calc(62) - calc(19))
# for i in range(4):
# print(input())
# import codecs
n = int(input().replace('\u202e', '').replace('\\u202e', ''))
for i in range(n):
l, r = [int(x.replace('\u202e', '').replace('\\u202e', '')) for x in input().split()]
x = calc(r) - calc(l - 1)
# print(l, r)
x = x % mod
# print(str(x)[::-1])
print("\u202e"+str(x), end = "")