結果

問題 No.2455 Numbers Dictionary
ユーザー ntudantuda
提出日時 2023-09-02 15:22:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 78,488 KB
最終ジャッジ日時 2023-09-02 15:22:38
合計ジャッジ時間 6,346 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,192 KB
testcase_01 AC 76 ms
71,368 KB
testcase_02 AC 161 ms
78,304 KB
testcase_03 AC 161 ms
77,880 KB
testcase_04 AC 191 ms
77,780 KB
testcase_05 AC 161 ms
78,292 KB
testcase_06 AC 163 ms
77,664 KB
testcase_07 AC 165 ms
77,800 KB
testcase_08 AC 154 ms
78,380 KB
testcase_09 AC 162 ms
77,672 KB
testcase_10 AC 158 ms
77,496 KB
testcase_11 AC 190 ms
77,656 KB
testcase_12 AC 161 ms
78,196 KB
testcase_13 AC 164 ms
77,500 KB
testcase_14 AC 166 ms
77,680 KB
testcase_15 AC 166 ms
77,896 KB
testcase_16 AC 165 ms
78,488 KB
testcase_17 AC 162 ms
78,284 KB
testcase_18 AC 165 ms
78,436 KB
testcase_19 AC 161 ms
78,484 KB
testcase_20 AC 166 ms
77,876 KB
testcase_21 AC 165 ms
77,848 KB
testcase_22 AC 167 ms
77,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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