結果
| 問題 |
No.1651 Removing Cards
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 17:02:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 727 bytes |
| コンパイル時間 | 589 ms |
| コンパイル使用メモリ | 82,276 KB |
| 実行使用メモリ | 92,512 KB |
| 最終ジャッジ日時 | 2025-06-12 17:02:35 |
| 合計ジャッジ時間 | 10,157 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 19 |
ソースコード
import sys
def find_last_card(K, N):
current_size = N
pos = 1
while current_size > 1:
# Compute the next size after one step
s = current_size - 1
m = s - (s // K)
# Compute the new position based on pos
a = (pos - 1) // (K - 1)
b = (pos - 1) % (K - 1) + 1
new_pos = a * K + b + 1
# Update current_size and pos
current_size = m
pos = new_pos
return pos
def main():
input = sys.stdin.read().split()
idx = 0
K = int(input[idx])
idx += 1
Q = int(input[idx])
idx += 1
for _ in range(Q):
N = int(input[idx])
idx += 1
print(find_last_card(K, N))
if __name__ == "__main__":
main()
gew1fw