A. Pineapple Incident

time limit per test

memory limit per test

input

output

t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1 second interval. Thus it barks at times tt + st + s + 1, t + 2st + 2s + 1, etc.

codeforces 697A Pineapple Incident_codeforces

x

Input

ts and x (0 ≤ t, x ≤ 109, 2 ≤ s ≤ 109) — the time the pineapple barks for the first time, the pineapple barking interval, and the time Barney wants to eat the pineapple respectively.

Output

x

Examples

Copy

3 10 4

Copy

NO

Copy

3 10 3

Copy

YES

Copy

3 8 51

Copy

YES

Copy

3 8 52

Copy

YES

Note

3, 13, 14, ..., so it won't bark at the moment 4 and will bark at the moment 3.

3, 11, 12, 19, 20, 27, 28, 35, 36, 43, 44, 51, 52, 59, ..., so it will bark at both moments 51 and 52.


水题,注意t,t+s,t+s+1,这三个要单独判断,后边的就是规律了

#include<bits/stdc++.h>  
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int main()
{
// freopen("shuju.txt","r",stdin);
int t,s,x;
cin>>t>>s>>x;
int flag=1;
if(x==t||x==t+s||x==t+s+1)
{
printf("YES\n");
flag=0;
}
else if(x<t+s+1)
{
printf("NO\n");
flag=0;
}
if(flag)
{
if((x-t)%s==0||(x-1-t)%s==0)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
return 0;
}