結果

問題 No.8133 ‮Reversed‪
コンテスト
ユーザー 👑 Nachia
提出日時 2026-04-01 23:10:27
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 1,013 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 182 ms
コンパイル使用メモリ 85,544 KB
実行使用メモリ 99,380 KB
最終ジャッジ日時 2026-04-01 23:10:59
合計ジャッジ時間 7,083 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 TLE * 2 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

M = 7000000001

def rev(x) :
    return int(str(x)[::-1], base=10) % M
def g(x) :
    ans = 0
    for i in range(1, x) :
        ans += rev(i)
    return ans
offset = g(10)
def f(x) :
    # print("g = " + str(g(x)))
    if x <= 15 :
        return g(x)
    ans = offset
    maxdig = len(str(x))
    for d in range(2, maxdig) :
        ans += int("1" * (d-1)) * 45 * pow(10, d-1, M) * 9
        ans += 45 * pow(10, (d-1), M)
    ti = 1
    h = 10 ** (maxdig)
    while x > 0 :
        maxdig -= 1
        for i in range(x % 10) :
            x -= 1
            ans += rev(x) * ti % M
        h //= 10
        x //= 10
        if x == 0 :
            break
        # print(f"{ans=}, {h=}, {x=}, {ti=}")
        ans += h * 45 * (x-(h//10)) * ti % M
        ti = ti * 10 % M
    ans %= M
    # print("f = " + str(ans))
    return ans

# print(g(100), f(100))
# print(g(104), f(104))
# print(g(96), f(96))

for t in range(int(input())) :
    l,r = map(int,input().split())
    ans = (f(r+1) - f(l)) % M
    print(ans)
0