题目等价于求 中的最大值,又因为 当且仅当 ,即:
-
若一组是最好的,则 且 。
-
否则,若二组是最好的,则 。
-
若均不满足,则三组是最好的。
另外本题卡精度,用 double 会拿到 分。
std如下:
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;cin>>t;
while(t--){
long long a,b,c,x,y,z;
cin>>a>>b>>c>>x>>y>>z;
if(a*y>=b*x && a*z>=c*x){
cout<<"1\n";
}else if(b*z>=c*y){
cout<<"2\n";
}else{
cout<<"3\n";
}
}
return 0;
}