形式化题意
是否存在一个正整数 满足 ,并且不存在非负整数 使得 或者 。
很水的题,模拟 , 即可,复杂度大约 。
具体注意事项见代码。
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,y,s,t;
signed main(){
cin>>n>>y>>s>>t;
for(int i=1;i<=n;i++){
int f1=1,f2=1;
for(int j=0;y+j*t<=i*s;j++)// 这里一定要写循环终止条件
if(y+j*t==i*s){// 不然会炸
f1=0;
break;
}
for(int j=0;y+j*t<=(i-1)*s;j++)// 这里也是
if(y+j*t==(i-1)*s){
f2=0;
break;
}
if(f1&&f2){
cout<<"Yes\n";
return 0;
}
}
cout<<"No\n";
return 0;
}