結果

問題 No.2455 Numbers Dictionary
ユーザー 👑 rin204
提出日時 2023-09-01 22:04:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 77,568 KB
最終ジャッジ日時 2025-01-03 08:42:19
合計ジャッジ時間 6,426 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n, k = map(int, input().split())
    ans = 0
    k = str(k)
    tot = 0
    for s in k:
        tot *= 10
        tot += int(s)
        if tot <= n:
            ans += 1
        for i in range(tot // 10 * 10, tot):
            if i == 0:
                continue
            di = 1
            t = i
            while t <= n:
                ans += max(0, min(n + 1, t + di) - t)
                t *= 10
                di *= 10

    print(ans)


for _ in range(int(input())):
    solve()
0