結果

問題 No.2455 Numbers Dictionary
ユーザー ntudantuda
提出日時 2023-09-02 13:53:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 86,792 KB
実行使用メモリ 78,512 KB
最終ジャッジ日時 2023-09-02 13:53:34
合計ジャッジ時間 6,556 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,948 KB
testcase_01 AC 74 ms
70,896 KB
testcase_02 AC 185 ms
77,704 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 184 ms
78,060 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 182 ms
78,156 KB
testcase_18 AC 158 ms
77,844 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(N, K):
    SN = str(N)
    NN = len(SN)
    SK = str(K)
    NK = len(SK)
    cnt = 0
    for i in range(1, int(SK[0])):
        for j in range(NN):
            start = i * 10 ** j
            if start > N:
                break
            tmp = start + 10 ** j - 1
            if tmp < N:
                end = tmp
                cnt += end - start + 1
            else:
                end = N
                cnt += end - start + 1
                break
    for i in range(NK):
        start = int(SK[0]) * 10 ** i
        tmp = int(SK[:i + 1])
        if tmp < K:
            end = tmp
            cnt += end - start + 1
        else:
            end = K
            cnt += end - start + 1
            break
    return cnt


T = int(input())
for t in range(T):
    N, K = map(int, input().split())
    print(solve(N, K))
0