結果
問題 | No.604 誕生日のお小遣い |
ユーザー |
![]() |
提出日時 | 2025-03-20 20:21:50 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 40 ms / 1,000 ms |
コード長 | 769 bytes |
コンパイル時間 | 387 ms |
コンパイル使用メモリ | 82,796 KB |
実行使用メモリ | 53,436 KB |
最終ジャッジ日時 | 2025-03-20 20:24:14 |
合計ジャッジ時間 | 2,216 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
A, B, C = map(int, input().split())if B == 1:print(C)else:low = 1high = C # We'll adjust high if needed, but initial high is C# Use binary search to find the minimal x such that x + (x//A)*(B-1) >= C# Adjust high if necessary in case the initial high is too lowdef compute_total(x):return x + (x // A) * (B - 1)# Check if with the current high the condition is satisfiedwhile compute_total(high) < C:high *= 2# Now perform binary search between low and highanswer = 0while low <= high:mid = (low + high) // 2total = compute_total(mid)if total >= C:answer = midhigh = mid - 1else:low = mid + 1print(answer)