結果

問題 No.3549 SigMax Digits (Judge ver.)
コンテスト
ユーザー detteiuu
提出日時 2026-05-30 17:37:29
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 1,378 ms / 3,000 ms
コード長 585 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 267 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 87,428 KB
最終ジャッジ日時 2026-05-30 17:37:38
合計ジャッジ時間 7,720 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from sys import stdin
input = stdin.readline

def func(limit):
    dp = [0]*10
    MAX = -1
    for i in range(18):
        n = limit//(10**(17-i))%10
        ndp = [0]*10
        for j in range(10):
            if dp[j] == 0: continue
            for k in range(10):
                ndp[max(j, k)] += dp[j]
        for j in range(n):
            ndp[max(MAX, j)] += 1
        MAX = max(MAX, n)
        dp = ndp
    ans = MAX
    for i in range(10):
        ans += dp[i]*i
    return ans

for _ in range(int(input())):
    L, R = map(int, input().split())

    print(func(R)-func(L-1))
0