QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#672346#9408. Hero of the KingdomREN_REN#RE 0ms0kbC++201.3kb2024-10-24 16:32:062024-10-24 16:32:11

Judging History

你现在查看的是最新测评结果

  • [2024-10-24 16:32:11]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-24 16:32:06]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define int long long
using i128 = __int128;
int n, k;
const int mod = 998244353;
int p, a, b, q, c, d, m, t;

void solve(){
    cin >> p >> a >> b;
    cin >> q >> c >> d;
    cin >> m >> t;
    a += c, b += d;
    while(1) {
         int i = min(m / p, (t - b) / a);
        // if(t < b) break;
        // if(m / p >= (t - b) / a) {
        //     int i = (t - b) / a;
        //     m += i * (q - p);
        //     break;
        // }
        // int i = m / p;
        // if(i <= 0) break;
        int tmaxc = t / (a * i + b);
        int gain = tmaxc * i * (q - p);
        if(m + gain >= p * (i + 1)) {
            int nd = p * (i + 1) - m;
            int ndx = (nd + (q - p) - 1) / (q - p);
            int ndc = (ndx + i - 1) / i;
            int ndt = a * ndc * i + b * ndc;
         //   cout << i << ' ' << nd << ' ' << ndx << ' ' << ndc << ' ' << ndt << ' ';
            t -= ndt;
            m += ndc * (q - p) * i;
       //     cout << t << ' ' << m << endl;
        } else {
            m += gain;
            break;
        }
    }
    cout << m << '\n';
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t = 1;
    cin >> t;
    while(t --){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3
5 2 3
8 1 5
14 36
5 2 0
8 1 3
17 6
100 1 0
10000 1 0
99 100000

output:


result: