結果
問題 |
No.1651 Removing Cards
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:57:55 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 599 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 82,632 KB |
実行使用メモリ | 92,544 KB |
最終ジャッジ日時 | 2025-03-20 20:58:15 |
合計ジャッジ時間 | 9,834 ms |
ジャッジサーバーID (参考情報) |
judge3 / 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 for _ in range(Q): N = int(input[ptr]) ptr += 1 stack = [] current = N while current > 1: stack.append(current) x = (current - 1) // K m = current - x - 1 current = m res = 1 while stack: current = stack.pop() res = ((res + 1) * K - 2) // (K - 1) print(res) if __name__ == "__main__": main()