A. Pineapple Incident
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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
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 4and 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.

思路:用sum表示barks的时间,如果x等于sum的话就输出yes,否则输出no,注意如果x==t的话也是可以的

 #include<bits/stdc++.h>
using namespace std;
int main()
{
int t,s,x;
cin>>t>>s>>x;
int sum=;
int i=;
int flag=;
if(t==x)
flag=;
else
{
while(sum<x)
{
sum=t+i*s;
if(sum==x)
{
flag=;
break;
}
sum=t+i*s+;
if(sum==x)
{
flag=;
break;
}
i++;
}
}
if(flag)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
return ;
}

Codeforces Round #362 (Div. 2)->A. Pineapple Incident的更多相关文章

  1. Codeforces Round #362 (Div. 2) A.B.C

    A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standar ...

  2. Codeforces Round #362 (Div. 2) A 水也挂

    A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standar ...

  3. Codeforces Round #362 (Div. 2)

    闲来无事一套CF啊,我觉得这几个题还是有套路的,但是很明显,这个题并不难 A. Pineapple Incident time limit per test 1 second memory limit ...

  4. Codeforces Round #362 (Div. 2) C. Lorenzo Von Matterhorn (类似LCA)

    题目链接:http://codeforces.com/problemset/problem/697/D 给你一个有规则的二叉树,大概有1e18个点. 有两种操作:1操作是将u到v上的路径加上w,2操作 ...

  5. #map+LCA# Codeforces Round #362 (Div. 2)-C. Lorenzo Von Matterhorn

    2018-03-16 http://codeforces.com/problemset/problem/697/C C. Lorenzo Von Matterhorn time limit per t ...

  6. 【转载】【树形DP】【数学期望】Codeforces Round #362 (Div. 2) D.Puzzles

    期望计算的套路: 1.定义:算出所有测试值的和,除以测试次数. 2.定义:算出所有值出现的概率与其乘积之和. 3.用前一步的期望,加上两者的期望距离,递推出来. 题意: 一个树,dfs遍历子树的顺序是 ...

  7. Codeforces Round #362 (Div. 2)->B. Barnicle

    B. Barnicle time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  8. Codeforces Round #362 (Div. 2) B 模拟

    B. Barnicle time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  9. Codeforces Round #362 (Div. 2) D. Puzzles

    D. Puzzles time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

随机推荐

  1. 20150309--gridview

    GridView: 使用代码套用模板,变为DataList的样式,添加<asp:TemplateField>标签,(注意必须加上<Columns>) <asp:GridV ...

  2. MATLAB学习(3)

    matlab读取图像并转化为灰度图像 image = imread('C:\Users\Administrator\Desktop\图像降噪\src\original image\100.png'); ...

  3. 【转】JavaScript里的this指针

    用自然语言的角度理解JavaScript中的this关键字 <script type="text/javascript"> function ftn03(){ var ...

  4. 基础学习总结(七)--子线程及Handler

    使用子线程获取网络图片1.采用httpUrlConnection直连方式获取图片2.采用子线程方式获取 <LinearLayout xmlns:android="http://sche ...

  5. 如何判断PHP 是ts还是nts版的

    通过phpinfo(); 查看其中的 Thread Safety 项,这个项目就是查看是否是线程安全,如果是:enabled,一般来说应该是ts版,否则是nts版.

  6. 通过百度地图API显示当前位置在地图上(图标显示)--第三方开源--百度地图(二)

    1.下载百度地图的demo,下载地址:http://lbsyun.baidu.com/sdk/download?selected=mapsdk_basicmap,mapsdk_searchfuncti ...

  7. How to using x++ creating Vendors [AX2012]

    .//Create party for the vendor public void createParty(VendorRequestCreate _vendorRequestCreate) { ; ...

  8. ros的源码阅读

    测试代码,使用xmlrpc与roscore通信 ros的框架是使用rpc与server端通信,server维护topic的publisher,subscriber,param server,servi ...

  9. python 内置模块之hashlib、hmac、uuid

    一.hashlib md5和sha算法通过消息摘要算法生成定长的消息摘要,消息摘要算法是不可逆的.但同一段消息通过摘要算法后得到的值是一样的,可一通过比对消息摘要验证数据的完整性. sha算法比MD5 ...

  10. perl中shift 和unshift 操作

    ##################################################################### unshift 和shift 对一个数组的开头进行操作(数组 ...