結果
| 問題 | No.8133 Reversed |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-01 21:54:28 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,427 bytes |
| 記録 | |
| コンパイル時間 | 212 ms |
| コンパイル使用メモリ | 85,108 KB |
| 実行使用メモリ | 168,988 KB |
| 最終ジャッジ日時 | 2026-04-01 21:55:07 |
| 合計ジャッジ時間 | 11,272 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 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] % mod * 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))