結果

問題 No.604 誕生日のお小遣い
コンテスト
ユーザー lam6er
提出日時 2025-03-20 20:21:50
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 36 ms / 1,000 ms
+ 507µs
コード長 769 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 82 ms
コンパイル使用メモリ 65,248 KB
実行使用メモリ 54,456 KB
最終ジャッジ日時 2026-10-13 13:17:45
合計ジャッジ時間 2,698 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

A, B, C = map(int, input().split())

if B == 1:
    print(C)
else:
    low = 1
    high = 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 low
    def compute_total(x):
        return x + (x // A) * (B - 1)
    
    # Check if with the current high the condition is satisfied
    while compute_total(high) < C:
        high *= 2

    # Now perform binary search between low and high
    answer = 0
    while low <= high:
        mid = (low + high) // 2
        total = compute_total(mid)
        if total >= C:
            answer = mid
            high = mid - 1
        else:
            low = mid + 1
    print(answer)
0