結果
| 問題 | No.2455 Numbers Dictionary | 
| コンテスト | |
| ユーザー |  sotanishy | 
| 提出日時 | 2023-09-01 22:15:51 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 898 bytes | 
| コンパイル時間 | 275 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 78,336 KB | 
| 最終ジャッジ日時 | 2025-01-03 09:06:40 | 
| 合計ジャッジ時間 | 8,494 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 8 WA * 14 | 
ソースコード
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)
            
            
            
        