简单题意
狗会在t时刻叫一声,之后每过s时间,他会叫两声,即在t+k*s和t+k*s+1时刻叫,给出一个时刻x,问狗会不会在x时刻叫
思路
当(x-t)%s ==0 或==1时叫,第一次特判,其他时间都不叫。
代码
#include <bits/stdc++.h>
using namespace std;
int main (){
int t,s,x;
cin >> t >> s >>x;
if(x == t){puts("YES"); return 0;}
if(x < s+t && x != t){puts("NO"); return 0;}
x -= t;
if(x < 0) {puts("NO");return 0;}
x %= s;
if(x ==0 || x == 1) puts("YES");
else puts("NO");
return 0;
}