QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#806827 | #9408. Hero of the Kingdom | jiangzhihui | WA | 0ms | 3836kb | C++14 | 1.7kb | 2024-12-09 15:47:56 | 2024-12-09 15:47:59 |
Judging History
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;
if(m<q){
cout<<m<<endl;
return ;
}
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)/z);//需合并的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: 3636kb
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: 0ms
memory: 3836kb
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:
279 17268784 8109756 117090495 538731 136625731 586 845 17864 4633 38782804 84606 16635 88588674 4502 2049 8823 1070452 134333292 495166 324797075 156 73 53895 57 4727693 47683 3764139838369 116942 85930322 4319452 996195 164701 8 6234251 14535 51109478 8316357 650174 131670 1289271 1906520 16513 24...
result:
wrong answer 1st lines differ - expected: '1886244', found: '279'