結果

問題 No.1651 Removing Cards
ユーザー gew1fw
提出日時 2025-06-12 21:45:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 517 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 91,752 KB
最終ジャッジ日時 2025-06-12 21:49:32
合計ジャッジ時間 8,087 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    input = sys.stdin.read
    data = input().split()
    idx = 0
    K = int(data[idx])
    idx += 1
    Q = int(data[idx])
    idx += 1
    for _ in range(Q):
        N = int(data[idx])
        idx += 1
        current_M = N
        result = 1
        while current_M > 1:
            m_marked = (current_M - 1) // K + 1
            current_M -= m_marked
            s = (result - 1) // (K - 1)
            result = 1 + result + s
        print(result)

if __name__ == "__main__":
    main()
0