「NLOI Round1」白鸟过河滩

· · 题解

题目等价于求 \frac{a}{x},\frac{b}{y},\frac{c}{z} 中的最大值,又因为 \frac{t1}{t2}\leq\frac{s1}{s2} 当且仅当 t1\times s2\leq s1\times t2 ,即:

另外本题卡精度,用 double 会拿到 85 分。

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;
}