結果
| 問題 |
No.1651 Removing Cards
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-04-24 12:20:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,169 bytes |
| コンパイル時間 | 312 ms |
| コンパイル使用メモリ | 82,508 KB |
| 実行使用メモリ | 93,528 KB |
| 最終ジャッジ日時 | 2025-04-24 12:22:50 |
| 合計ジャッジ時間 | 11,341 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 19 |
ソースコード
import sys
def main():
input = sys.stdin.read().split()
idx = 0
K = int(input[idx])
idx += 1
Q = int(input[idx])
idx += 1
queries = [int(input[idx + i]) for i in range(Q)]
for N in queries:
if N == 1:
print(1)
continue
steps = []
current = N
while current > 1:
steps.append(current)
m = (current - 1 + K) // K
current = current - m
steps.append(1)
steps.reverse()
ans = 1
for n in steps[1:]:
m = (n - 1 + K) // K
p = ans
if K == 1:
original_pos = p + 1
else:
threshold = (m - 1) * (K - 1)
if p <= threshold:
block_x = (p - 1) // (K - 1)
pos_in_block = (p - 1) % (K - 1) + 1
original_pos = block_x * K + 1 + pos_in_block
else:
offset = p - threshold
original_pos = (m - 1) * K + 1 + offset
ans = original_pos
print(ans)
if __name__ == '__main__':
main()
qwewe