結果

問題 No.2455 Numbers Dictionary
ユーザー 👑 rin204rin204
提出日時 2023-09-01 22:04:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 78,892 KB
最終ジャッジ日時 2023-09-01 22:04:42
合計ジャッジ時間 6,233 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,612 KB
testcase_01 AC 71 ms
71,260 KB
testcase_02 AC 176 ms
77,912 KB
testcase_03 AC 168 ms
77,872 KB
testcase_04 AC 258 ms
77,724 KB
testcase_05 AC 161 ms
77,824 KB
testcase_06 AC 222 ms
78,064 KB
testcase_07 AC 239 ms
78,076 KB
testcase_08 AC 204 ms
77,960 KB
testcase_09 AC 239 ms
78,252 KB
testcase_10 AC 203 ms
78,472 KB
testcase_11 AC 224 ms
78,276 KB
testcase_12 AC 172 ms
77,892 KB
testcase_13 AC 226 ms
78,044 KB
testcase_14 AC 264 ms
78,500 KB
testcase_15 AC 225 ms
78,892 KB
testcase_16 AC 157 ms
78,544 KB
testcase_17 AC 213 ms
77,876 KB
testcase_18 AC 162 ms
77,768 KB
testcase_19 AC 165 ms
77,840 KB
testcase_20 AC 201 ms
78,380 KB
testcase_21 AC 202 ms
77,940 KB
testcase_22 AC 168 ms
77,688 KB
権限があれば一括ダウンロードができます

ソースコード

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