結果

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

ソースコード

diff #
raw source code

from sys import stdin
input = stdin.readline

def func(limit):
    dp = [[[0]*10 for _ in range(2)] for _ in range(19)]
    dp[0][0][0] = 1
    for i in range(18):
        n = limit//(10**(17-i))%10
        for small in range(2):
            for j in range(10):
                if dp[i][small][j] == 0: continue
                for k in range(10 if small else n+1):
                    dp[i+1][small or k < n][max(j, k)] += dp[i][small][j]
    ans = 0
    for i in range(2):
        for j in range(10):
            ans += dp[-1][i][j]*j
    return ans

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

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