結果
| 問題 |
No.1651 Removing Cards
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-05-14 13:24:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,361 bytes |
| コンパイル時間 | 283 ms |
| コンパイル使用メモリ | 82,668 KB |
| 実行使用メモリ | 80,036 KB |
| 最終ジャッジ日時 | 2025-05-14 13:25:52 |
| 合計ジャッジ時間 | 9,087 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 19 |
ソースコード
def solve():
K_val, Q_val = map(int, input().split())
results = []
for _ in range(Q_val):
N_orig = int(input())
if N_orig <= K_val:
results.append(N_orig)
continue
# Calculate s: number of steps
s = 0
current_N = N_orig
while current_N > 1:
if current_N <= K_val:
s += (current_N - 1)
current_N = 1 # To exit loop
else:
# current_N > K_val
removed_count = (current_N - 1) // K_val + 1
current_N -= removed_count
s += 1
# Calculate ans based on s steps
ans_val = 1
if K_val == 1: # Constraint K >= 2, so K-1 >= 1
# This case should not be reached. If it were K=1, all cards but one might be removed.
# Or if N_orig > 1, all cards are removed. This case is ill-defined for K=1.
# Since K >= 2, K-1 >= 1.
pass
for _i_step in range(s):
# ans_val_minus_1 = ans_val - 1
# term_to_add = ans_val_minus_1 // (K_val - 1)
# ans_val = ans_val + 1 + term_to_add
ans_val = ans_val + 1 + (ans_val - 1) // (K_val - 1)
results.append(ans_val)
for res in results:
print(res)
solve()
qwewe