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. Cocos2d-JS内置粒子系统

    从类图中我们可以看到,Cocos2d-JS中有内置的11种粒子,这些粒子的属性都是预先定义好的,我们也可以在程序代码中单独修改某些属性,我们在上一节的实例中都已经实现了这些属性的设置.内置粒子系统内置 ...

  2. Ajax的ActionLink方法(适用于异步加载)

    8.2.1  AJAX的ActionLink方法 在Razor视图中,AJAX辅助方法可以通过Ajax属性访问.和HTML辅助方法类似,Ajax属性上的大部分AJAX辅助方法都是扩展方法(除了Ajax ...

  3. VxWorks 6.9 内核编程指导之读书笔记 -- ISRs和Watchdog Timer

    中断服务程序 ISR 硬件中断处理是实时系统的关键,因为它是外部时间通知系统的方式. ISR亦称为中断处理函数,是对中断的正确响应.可以使用任何ISR连接到任何没有被VxWorks使用的中断上.当关联 ...

  4. 页面传值总结Block

    // AppDelegate.m // 页面传值总结 // // Created by qianfeng on 15/6/13. // Copyright (c) 2015年 qianfeng. Al ...

  5. 7款震撼人心的HTML5文字特效

    1.CSS3五彩文字特效 文字带阴影效果 这是一款非常具有卡通形象的CSS3五彩文字特效,虽然没有迷人的动画效果,但是五彩缤纷的文字展现在屏幕上也是非常酷的,再加上每一个文字都有不同角度的阴影效果,加 ...

  6. jquery获取html元素的绝对位置和相对位置

    jquery获取html元素的绝对位置坐标和相对父元素的位置坐标方法:绝对位置坐标:$("#elem").offset().top$("#elem").offs ...

  7. 《如何将windows上的软件包或文件上传到linux服务上》

    昨天晚上朋友让我帮他简单的搭建个环境,他公司让他做款软件测试温度的,他自己搞的是嵌入式,在公司担任的是软件工程师,应届毕业生.也可能他们搞嵌入式的对这个linux系统不太熟,不会把windows上的软 ...

  8. lnmp下配置虚拟主机

    一:首先熟悉几个命令 which php      --->  which是通过 PATH环境变量到该路径内查找可执行文件,所以基本的功能是寻找可执行文件 whereis php   ----& ...

  9. NSS_05 数据访问选型

    在数据访问层上很想用orm框架, 选用Nhibernate或ef, 可以直接操作类对象, 避免转换, 更加的面向对象,更重要的是开发起来就方便多了. 但是从网上了解到这些框架太高级了, 用得不好到时会 ...

  10. php生成圆形图片

    http://files.cnblogs.com/files/adtuu/circle_image.zip