QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#662715 | #9408. Hero of the Kingdom | Scene# | TL | 0ms | 3804kb | C++14 | 790b | 2024-10-21 09:26:12 | 2024-10-21 09:26:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int read(){
int ret=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
while( isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch&15);ch=getchar();}
return ret*f;
}
int T,a,b,c,d,p,q;
long long m,t;
int main(){
T=read();
while(T--){
p=read(),a=read(),b=read();
q=read(),c=read(),d=read();
m=read(),t=read();
while(1){
int num1=(t-b-d)/(a+c),num2=m/p;
int num=min(num1,num2);
if(num<=0) break;
if(num1==num){
t-=1ll*(a+c)*num+b+d;
m+=1ll*(q-p)*num;
}else{
int t1=t/(1ll*(a+c)*num+b+d),t2=ceil(1.0*((num+1)*p-m)/(1ll*(q-p)*num));
int tt=min(t1,t2);
t-=tt*(1ll*(a+c)*num+b+d);
m+=tt*(1ll*(q-p)*num);
}
}
printf("%lld\n",m);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
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...