Pineapple Incident(水题)

                                            A. Pineapple Incident

Ted has a pineapple. This pineapple is able to bark like a bulldog! At time 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.

                                                                                      

Barney woke up in the morning and wants to eat the pineapple, but he can't eat it when it's barking. Barney plans to eat it at time x (in seconds), so he asked you to tell him if it's gonna bark at that time.

Input

The first and only line of input contains three integers 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

Print a single "YES" (without quotes) if the pineapple will bark at time x or a single "NO" (without quotes) otherwise in the only line of output.

Examples

input

Copy

3 10 4

output

Copy

NO

input

Copy

3 10 3

output

Copy

YES

input

Copy

3 8 51

output

Copy

YES

input

Copy

3 8 52

output

Copy

YES

Note

In the first and the second sample cases pineapple will bark at moments 3, 13, 14, ..., so it won't bark at the moment 4 and will bark at the moment 3.

In the third and fourth sample cases pineapple will bark at moments 3, 11, 12, 19, 20, 27, 28, 35, 36, 43, 44, 51, 52, 59, ..., so it will bark at both moments 51 and 52.

题意很简单,但是有个坑,就是x小于t的情况,相减是负数但是模下来也可能是0。

做这种水题的时候可以多加几个看似累赘的逻辑,防止出错。

#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define pii pair<ll,ll>
using namespace std;
int main()
{
    ll t,s,x;
    scanf("%I64d%I64d%I64d",&t,&s,&x);
    int flag=0;

    if(x>=t)
    {
        if(s==2&&x>=t+s) flag=1;

        if(x-t==0)flag=1;
        if((x-t)%s==0)flag=1;

        if(x>(s+t)&&(x-t-1)%s==0)flag=1;

    }
    
    if(flag)printf("YES\n");
    else printf("NO\n");
    return 0;
}

猜你喜欢

转载自blog.csdn.net/sadsummerholiday/article/details/81410521