Pineapple Incident
来源:互联网 发布:淘宝直通车助手官网 编辑:程序博客网 时间:2024/06/07 08:05
Description
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 + 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, s 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.
Sample Input
3 10 4
NO
3 10 3
YES
3 8 51
YES
3 8 52
YES
Hint
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)%s=1||0就ok了,还有2个特别判断,就是当x=t+1和x<t时的情况.
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){long long t,s,x,i;while(scanf("%lld%lld%lld",&t,&s,&x)!=EOF){int flag=0;if(x==t)flag=1;else if(x<t)flag=0;else if(x==t+1)flag=0;else {if((x-t)%s==1||(x-t)%s==0)flag=1;}if(flag==0)printf("NO\n");elseprintf("YES\n");}return 0;}
- Pineapple Incident
- A. Pineapple Incident
- Codeforces 697A - Pineapple Incident
- CodeForces 697A Pineapple Incident
- Codeforces 697A. Pineapple Incident (模拟)
- CodeForces 697 A. Pineapple Incident(水~)
- cdeforces 697 A. Pineapple Incident (数学)
- codeforces #362(div.2)A.Pineapple Incident【水题】
- Codeforces Round #362 (Div. 2) A. Pineapple Incident
- Pineapple Incident,Barnicle,Lorenzo Von Matterhorn(cf#362)
- 【Codeforces Round 362 (Div 2)A】【简单讨论】Pineapple Incident
- CodeForces 697A Pineapple Incident(数列,水下题)
- Codeforces Round #362 (Div. 2) A. Pineapple Incident
- Codeforces Round #362 (Div. 2) A. Pineapple Incident(水题)
- Service Support-Incident Management
- incident impendence coefficient
- Incident Packaging Service
- wifi pineapple | WiFiPineapple plus 基本使用教程
- angular-translate for i18n and I10n
- python计算tfidf
- 图结构练习——判断给定图是否存在合法拓扑序列
- 贪心(弱)已知当前排名,倒推上月排名
- NSUserDefaults的使用
- Pineapple Incident
- android Activity(活动)详解
- POJ 1276 Cash Machine
- USB通讯
- socket网络服务器
- 设置Ubuntu纯英文环境
- java web文件上传总结
- Java中迭代器是什么?
- Android 自定义View 常用菜单的中的Table