結果

問題 No.2455 Numbers Dictionary
ユーザー sotanishysotanishy
提出日時 2023-09-01 22:15:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 898 bytes
コンパイル時間 818 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 80,168 KB
最終ジャッジ日時 2023-09-01 22:16:01
合計ジャッジ時間 9,828 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,684 KB
testcase_01 AC 74 ms
71,056 KB
testcase_02 AC 194 ms
78,432 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 206 ms
78,644 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 381 ms
79,064 KB
testcase_11 AC 437 ms
78,836 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 385 ms
79,024 KB
testcase_16 WA -
testcase_17 AC 571 ms
79,304 KB
testcase_18 AC 171 ms
78,848 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline


def calc(digits, N):
    if digits < N[:len(digits)]:
        d = 0
        cnt = 0
        while len(digits) + d <= len(N):
            cnt += 10**d
            d += 1
        return cnt
    if digits > N[:len(digits)]:
        d = 0
        cnt = 0
        while len(digits) + d <= len(N) - 1:
            cnt += 10**d
            d += 1
        return cnt

    res = 0
    cnt = 1 if digits else 0
    for d in range(len(digits), len(N)):
        res = res * 10 + N[d]
        cnt += res
    cnt += 1
    return cnt


T = int(input())
for _ in range(T):
    N, K = map(int, input().split())
    N = list(map(int, str(N)))
    K = list(map(int, str(K)))
    ans = 0

    for i, x in enumerate(K):
        for y in range(x):
            if i == 0 and y == 0:
                continue
            ans += calc(K[:i] + [y], N)
        ans += 1

    print(ans)
0