結果
問題 | No.1651 Removing Cards |
ユーザー |
![]() |
提出日時 | 2025-06-12 21:40:41 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 567 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 81,944 KB |
実行使用メモリ | 328,520 KB |
最終ジャッジ日時 | 2025-06-12 21:44:51 |
合計ジャッジ時間 | 8,384 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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()