結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,404 KB
testcase_01 AC 72 ms
71,388 KB
testcase_02 AC 191 ms
78,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 203 ms
78,412 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 411 ms
78,960 KB
testcase_11 AC 445 ms
79,252 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 383 ms
78,952 KB
testcase_16 WA -
testcase_17 AC 635 ms
79,680 KB
testcase_18 AC 165 ms
78,656 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)]:
        cnt = 0
        for d in range(len(N)-len(digits)+1):
            cnt += 10**d
        return cnt
    if digits > N[:len(digits)]:
        cnt = 0
        for d in range(len(N)-len(digits)):
            cnt += 10**d
        return cnt

    res = 0
    cnt = 1
    for d in range(len(digits), len(N)):
        res = res * 10 + N[d]
        cnt += res + 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