結果
問題 |
No.1651 Removing Cards
|
ユーザー |
![]() |
提出日時 | 2025-06-12 17:03:21 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 567 bytes |
コンパイル時間 | 865 ms |
コンパイル使用メモリ | 82,016 KB |
実行使用メモリ | 328,176 KB |
最終ジャッジ日時 | 2025-06-12 17:03:30 |
合計ジャッジ時間 | 9,490 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 TLE * 1 -- * 19 |
ソースコード
import sys def last_card(N, K): if N == 1: return 1 stack = [] while N > 1: M = N - ((N + K - 1) // K) stack.append((N, K)) N = M f = 1 while stack: N, K = stack.pop() x = ((f - 1) // (K - 1)) + 1 f += x return f 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(last_card(N, K)) if __name__ == "__main__": main()