题解十七:P16353 「Diligent-OI R3 A」说好不哭
【LGR-280-Div.2】洛谷 4 月月赛 III & Diligent-OI Round 3-P16353 「Diligent-OI R3 A」说好不哭。
如果
如果
所以这种情况一定符合条件。
第三种:x>0>y ,即 x 、y 异号
可以类比第二种,令序列第一项为
所以这种情况也一定符合条件。
第四种:0>x \ge y ,即 x 、y 均为负数
将
代码
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll t,n,x,y;
bool work(){
if(n==1)
if(x!=y) return false;
else return true;
if(x>0 and y<0)
return true;
if(y==0 or x==0)
return true;
if(x<0){
y=-y,x=-x;
swap(x,y);
}
if(x<y*n) return false;
return true;
}
int main(){
cin>>t;
while(t--){
cin>>n>>x>>y;
if(!work()) cout<<"NO\n";
else cout<<"YES\n";
}
return 0;
}// 434ms / 788.00KB / 406B C++98 O2
//求赞 QAQ
另外
欢迎接着看看月赛第二题的题解:《题解十八:「Diligent-OI R3 B」天际线》。