QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#806792#9408. Hero of the KingdomjiangzhihuiWA 2ms3520kbC++141.7kb2024-12-09 15:16:362024-12-09 15:16:36

Judging History

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

  • [2024-12-09 15:16:36]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3520kb
  • [2024-12-09 15:16:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
/*
1
5 2 0
8 1 3
17 6
*/
    int p,a,b,q,c,d,m,t;
    cin>>p>>a>>b;
    cin>>q>>c>>d;
    cin>>m>>t;
    while(t>=a+c+b+d){//至少剩余时间要能再买一袋才可
        int bg=m/p;//当前的钱能买多少袋
        if(bg==0){
            cout<<m<<endl;
            return ;
        }
        int z=bg*(q-p);//当前一次性能赚这么多钱
        // 如果买一次的时间都不够怎么办:
        if(t<((bg)*(a+c)+b+d)){
            // cout<<(t-b-d)/(a+c)<<endl;
            cout<<m+(t-b-d)/(a+c)*(q-p)<<endl;
            return ;
        }
        if((z+m)/p == bg){//买一次后钱不够合并次数买
            //多买一袋需要的钱是
            int zm=(bg+1)*p;
            //若时间足够那我直接买到能多买一袋为止的次数
            int cm=ceil(1.0*(zm-m)/(q-p));//需合并的c次
            //若时间不足
            int ct=t/((a+c)*bg+b+d);
            if(ct<cm){//时间不足最后一次交易
                m+=ct*z;
                cout<<m<<endl;
                return ;
            }else{//按原计划进行cm次
                m+=cm*z;
                t-=(cm)*((a+c)*bg+b+d);
            }
        }else{//一次一次买
            //时间可能不够
            // if(t<((bg)*(a+c)+b+d)){
            //     cout<<m+(t-b-d)/(a+c)*(q-p)<<endl;
            //     return ;
            // }
            t-=((bg)*(a+c)+b+d);
            m+=z;
        }
    }
    cout<<m<<endl;
}
signed main(){
    // freopen("1.in","r",stdin);
    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: 3476kb

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
Wrong Answer
time: 2ms
memory: 3520kb

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
17268784
8109756
117090495
538731
136625731
586
25929035
17864
7905961573
38782804
670869825
16607
88588674
4502
3995
6228362563
1070452
134333292
495166
324797075
156
598405696216
53895
3503164
4727693
124349483
3764139838369
2840566939118
85930322
4319452
996195
54156125533
32693
216299285...

result:

wrong answer 13th lines differ - expected: '16635', found: '16607'