結果

問題 No.3549 SigMax Digits (Judge ver.)
コンテスト
ユーザー titia
提出日時 2026-05-23 00:09:41
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 649 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 348 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 433,872 KB
最終ジャッジ日時 2026-05-23 00:10:05
合計ジャッジ時間 8,679 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

from functools import lru_cache
@lru_cache(maxsize=None)
def calc(N,m):
    #print(N,m)

    if N<=9:
        ANS=0
        for i in range(N+1):
            ANS+=max(i,m)
        return ANS

    now=1
    for i in range(1,20):
        if N>=now:
            keta=now
        else:
            break
        now=now*10

    ANS=0
    x=N//keta

    #print(keta,x)
    for i in range(x):
        ANS+=calc(keta-1,max(i,m))
    ANS+=calc(N%keta,max(x,m))

    return ANS

    
    
    

t=int(input())

for tests in range(t):
    L,R=list(map(int,input().split()))

    ANS=calc(R,0)-calc(L-1,0)

    print(ANS)
0