結果
| 問題 |
No.1651 Removing Cards
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:11:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 594 bytes |
| コンパイル時間 | 291 ms |
| コンパイル使用メモリ | 82,724 KB |
| 実行使用メモリ | 331,972 KB |
| 最終ジャッジ日時 | 2025-06-12 14:12:44 |
| 合計ジャッジ時間 | 9,647 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 19 |
ソースコード
import sys
def main():
input = sys.stdin.read().split()
ptr = 0
K = int(input[ptr])
ptr += 1
Q = int(input[ptr])
ptr += 1
queries = [int(input[ptr + i]) for i in range(Q)]
for N in queries:
stack = []
current_n = N
while current_n > 1:
m = (current_n - 1) // K + 1
stack.append((current_n, m))
current_n -= m
x = 1
while stack:
current_n, m = stack.pop()
q = (x - 1) // (K - 1)
x += q + 1
print(x)
if __name__ == "__main__":
main()
gew1fw