結果
| 問題 |
No.1651 Removing Cards
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 17:02:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 467 bytes |
| コンパイル時間 | 184 ms |
| コンパイル使用メモリ | 82,368 KB |
| 実行使用メモリ | 92,544 KB |
| 最終ジャッジ日時 | 2025-06-12 17:02:51 |
| 合計ジャッジ時間 | 7,783 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 19 |
ソースコード
import sys
def compute_last_card(n, K):
res = 0
while n > 1:
r = (n - 1) // K + 1
m = n - r
if m == 0:
break
s = res // (K - 1)
res = res + s + 1
n = m
return res + 1
def main():
input = sys.stdin.read().split()
K = int(input[0])
Q = int(input[1])
for i in range(2, 2 + Q):
N = int(input[i])
print(compute_last_card(N, K))
if __name__ == "__main__":
main()
gew1fw