結果
| 問題 |
No.2455 Numbers Dictionary
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2023-09-02 15:22:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 129 ms / 2,000 ms |
| コード長 | 527 bytes |
| コンパイル時間 | 202 ms |
| コンパイル使用メモリ | 82,580 KB |
| 実行使用メモリ | 77,328 KB |
| 最終ジャッジ日時 | 2024-06-11 21:56:37 |
| 合計ジャッジ時間 | 4,044 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 22 |
ソースコード
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))
ntuda