思路:
根据n,max,min来确定平均值的范围即可。
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
double maxx,minn,ave;
cin>>maxx>>minn>>ave;
if(maxx < minn || ave < minn || ave > maxx)
{
cout<<"no"<<endl;
continue;
}
maxx = (n-1)*maxx+minn,maxx/=n;
minn = (n-1)*minn+maxx,minn/n;
if(ave >= minn && ave <= maxx)cout<<"yes"<<endl;
}
}