QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#806897#9408. Hero of the KingdomjiangzhihuiTL 0ms3640kbC++14643b2024-12-09 16:40:592024-12-09 16:40:59

Judging History

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

  • [2024-12-09 16:40:59]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3640kb
  • [2024-12-09 16:40:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
void solve(){
    int a,b,c,d,p,q,m,t;
    cin>>p>>a>>b;
    cin>>q>>c>>d;
    cin>>m>>t;
    if(m<p){
        cout<<m<<endl;
        return ;
    }
    while (true){
        int bg=m/p;//一次性能买几个
        int ll=ceil(1.0*(p*(bg+1)-m)/(q-p));//需要买几轮
        if(t<ll*((a+c)*bg+b+d)){
            m+=max(0,(t-b-d)/(a+c))*(q-p);
            cout<<m<<endl;
            break;
        }
        t-=ll*((a+c)*bg+b+d);
        m+=ll*(bg*(q-p));
    }
}
int main(){
    int qes;
    cin>>qes;
    while(qes--)solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3640kb

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:

32
20
99

result:

ok 3 lines

Test #2:

score: -100
Time Limit Exceeded

input:

500
252 34074578 3386884
628907 1207868 18
279 125908043
17268783 50414369 277106
17532337 45 0
17268784 4606
5506 3465964 19
5543 4786900 7
8109756 50825
23718927 66546966 0
23718931 96 0
117090491 99433206
537909 33389755 4
537910 1362118 0
538731 3
47 117 17333
1724743 7699 402536
79710763 684241...

output:

1886244
69452476
8109756
123107067
4303272
136625731
586
67614371
17864
-515867303
719935382
670869825
16627
571716990
4502
7887
287122323
2666667
135039489
495166
324797075
156
866583020
53895
1709245241
14723917
124349483
815369250
-151284982
85930522
4319452
-390835439
1876929501
32693
-108502544...

result: