QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#806847 | #9408. Hero of the Kingdom | jiangzhihui | WA | 0ms | 3720kb | C++14 | 1.0kb | 2024-12-09 16:07:18 | 2024-12-09 16:07:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+5;
void solve(){
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 ;
}
int bg,t1,ll;
while(1){
bg=m/p;//当前这些钱能买bg袋
t1=(a+c)*bg+b+d;//买一次的时间
ll=ceil(1.00*(p*(bg+1)-m)/((q-p)*bg));//需要买几次才能多买一袋
if(ll*t1>t){
m+=t/t1*(q-p)*bg;//先能买几轮就买几轮
t-=t/t1*t1;
break;//不够买ll轮
}
t-=ll*t1;
m+=ll*(q-p)*bg;
}
//跳出来之后得看一下还能买几个面粉
// int lst=(t-b-d)/(a+c);
// m+=(q-p)*lst;
int l=0,r=t+1;
while(l+1!=r){
int mid=l+r>>1;
if(a*mid+b+c*mid+d<=t)l=mid;
else r=mid;
}
m+=(q-p)*l;
cout<<m<<endl;
}
signed main(){
int ques;
cin>>ques;
while(ques--)solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
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: 3720kb
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 85930522 4319452 996195 164701 8 6234251 14535 51109478 8316357 650174 131670 1289271 1906520 16513 24...
result:
wrong answer 1st lines differ - expected: '1886244', found: '279'