题解:P16953 「NLOI Round1」白鸟过河滩

· · 题解

题目传送门

解题思路

这道题是基础的模拟题。

题目大意

题目让我们求出演唱效果除以人数的结果最大的一组,如果有多组,就输出最小编号组。

思路

我们先求每组的演唱效果除以人数的结果,如果有多组最大,我们就输出最小编号,我们可以从编号 1 开始判断,这样就可以做到多组最小。

AC code:

#include<bits/stdc++.h>
using namespace std;
int main(){
    int T;
    cin>>T;
    while(T--){
        long double a,b,c,x,y,z;
        cin>>a>>b>>c>>x>>y>>z;
        long double sum=a/x,cnt=b/y,ans=c/z;
        long double maxx=max({sum,cnt,ans});
        if(sum==maxx){
            cout<<1<<endl;
        }else if(cnt==maxx){
            cout<<2<<endl;
        }else if(ans==maxx){
            cout<<3<<endl;
        }
    }
    return 0;
}