結果
問題 |
No.1651 Removing Cards
|
ユーザー |
![]() |
提出日時 | 2025-05-14 12:47:23 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 682 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 82,840 KB |
実行使用メモリ | 269,364 KB |
最終ジャッジ日時 | 2025-05-14 12:48:07 |
合計ジャッジ時間 | 9,604 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 = list(map(int, input[idx:idx+Q])) for N in queries: if N == 1: print(1) continue path = [] current = N while True: path.append(current) if current == 1: break s = (current - 1) // K + 1 current -= s path.reverse() ans = 1 for n in path[1:]: ans += (ans - 1) // (K - 1) + 1 print(ans) if __name__ == '__main__': main()