【題解】AtCoder ABC 180D – Takahashi Unevolved

【題目敘述】https://atcoder.jp/contests/abc180/tasks/abc180_d

#include <bits/stdc++.h>
using namespace std;

long long x, y, a, b, ans, cnt;

int main(){
    cin >> x >> y >> a >> b;
    y--;
    ans = (y-x)/b;
    while (y/x >= a){
        x *= a;
        cnt++;
        ans = max(ans, (y-x)/b+cnt);
    }
    cout << ans << "\n";
}

分享本文 Share with friends