求问正确做法
查看原帖
求问正确做法
537934
litjohn楼主2024/3/18 18:24
#include <bits/stdc++.h>

using namespace std;
#define ll long long
ll t, x, a, b;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> t;
    for (ll i = 0; i < t; ++i) {
        cin >> x >> a >> b;
        if (a > b) {
            cout << x << endl;
            continue;
        } else if (x == 0 || a == 0) {
            cout << -b << endl;
            continue;
        } else if (b == 0) {
            cout << x << endl;
            continue;
        } else {
            ll ans = x;
            for (ll j = 0; j < 1000000 && ans >= 0; ++j) {
                if (ans * a - b > ans) {
                    break;
                }
                ans = min(ans, ans * a - b);
            }
            cout << ans << endl;
        }
    }
    return 0;
}

这是我赛时的代码,wa了最后三个点,这是为什么呢?求大佬解释。

另:本题正确做法是什么?

2024/3/18 18:24
加载中...