結果
| 問題 |
No.1651 Removing Cards
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-05-14 12:47:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 600 bytes |
| コンパイル時間 | 279 ms |
| コンパイル使用メモリ | 82,588 KB |
| 実行使用メモリ | 93,452 KB |
| 最終ジャッジ日時 | 2025-05-14 12:49:45 |
| 合計ジャッジ時間 | 8,778 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / 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:
steps = []
current = N
while current > 1:
m = (current + K - 1) // K
steps.append(m)
current -= m
x = 1
for m in reversed(steps):
q = (x - 1) // (K - 1)
r = (x - 1) % (K - 1)
x = q * K + r + 2
print(x)
if __name__ == '__main__':
main()
qwewe