Pineapple Incident

Pineapple Incident

Problem

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 t , t   +   s , t   +   s   +   1 , t   +   2 s , t   +   2 s   +   1 t, t + s, t + s + 1, t + 2s, t + 2s + 1 t,t+s,t+s+ 1,t+ 2s,t+ 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 t t t, s s s and x x x ( 0   ≤   t ,   x   ≤   1 0 9 , 2   ≤   s   ≤   1 0 9 ) (0 ≤ t, x ≤ 10^9, 2 ≤ s ≤ 10^9) (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
3 10 4
Output
NO
Input
3 10 3
Output
YES
Input
3 8 51
Output
YES
Input
3 8 52
Output
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.

Code

// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <sstream>//整型转字符串
// #include <stack>//栈
// #include <deque>//堆/优先队列
// #include <queue>//队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ll t,s,x;
    cin>>t>>s>>x;

    if(t>x) cout<<"NO"<<endl;
    else if(t==x) cout<<"YES"<<endl;
    else
    {
        ll op=x-t;
        //3 10 4,特殊
        if((op%s==0||op%s==1)&&op!=1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    
    return 0;
}
  • 10
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Pretty Boy Fox

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值