結果
問題 |
No.2099 [Cherry Alpha B] Time Machine
|
ユーザー |
|
提出日時 | 2025-05-01 14:36:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 480 ms / 2,000 ms |
コード長 | 909 bytes |
コンパイル時間 | 382 ms |
コンパイル使用メモリ | 82,416 KB |
実行使用メモリ | 75,428 KB |
最終ジャッジ日時 | 2025-05-01 14:37:00 |
合計ジャッジ時間 | 12,535 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 72 |
ソースコード
## https://yukicoder.me/problems/no/2099 def main(): T = int(input()) X, A = map(int, input().split()) Y, B = map(int, input().split()) # yが取りうる最小値を取得 if T >= 0: y_min = 0 else: y_min = (- T) // B + (1 if (-T) % B > 0 else 0) # 本処理 min_answer = float("inf") t = (T + y_min * B) % A cost = y_min # 一発目 xx = T + cost * B answer = cost * Y + t xx0 = xx - t a = xx0 // A answer += a * X min_answer = min(min_answer, answer) first = t cost += 1 t += B t %= A while t != first: xx = T + cost * B answer = cost * Y + t xx0 = xx - t a = xx0 // A answer += a * X min_answer = min(min_answer, answer) cost += 1 t += B t %= A print(min_answer) if __name__ == "__main__": main()