Codeforces Round #362 (Div. 2) A. Pineapple Incident
来源:互联网 发布:织梦分类信息源码 编辑:程序博客网 时间:2024/05/21 17:58
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 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.
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.
题意:如题,判断t能不能到达s,每次+x,要判断当前和当前+1
思路:直接模拟就可以了
ac代码:
#include<stdio.h>#include<math.h>#include<string.h>#include<stack>#include<set>#include<queue>#include<vector>#include<iostream>#include<algorithm>#define MAXN 1010000#define LL long long#define ll __int64#define INF 0xfffffff#define mem(x) memset(x,0,sizeof(x))#define PI acos(-1)#define eps 1e-8using namespace std;ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}ll lcm(ll a,ll b){return a/gcd(a,b)*b;}ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}double dpow(double a,ll b){double ans=1.0;while(b){if(b%2)ans=ans*a;a=a*a;b/=2;}return ans;}//headint main(){ int t,x,s;scanf("%d%d%d",&t,&x,&s); int bz=0; if(t==s) bz=1;t+=x; for(int i=t;i<=s;i+=x){ if(i==s||i+1==s){ bz=1; break; } } printf(bz?"YES\n":"NO\n"); return 0;}
- Codeforces Round #362 (Div. 2) A. Pineapple Incident
- 【Codeforces Round 362 (Div 2)A】【简单讨论】Pineapple Incident
- Codeforces Round #362 (Div. 2) A. Pineapple Incident
- Codeforces Round #362 (Div. 2) A. Pineapple Incident(水题)
- codeforces #362(div.2)A.Pineapple Incident【水题】
- Codeforces 697A - Pineapple Incident
- CodeForces 697A Pineapple Incident
- Codeforces 697A. Pineapple Incident (模拟)
- CodeForces 697 A. Pineapple Incident(水~)
- A. Pineapple Incident
- CodeForces 697A Pineapple Incident(数列,水下题)
- Pineapple Incident
- Codeforces Round #362 (Div. 2) A,B
- cdeforces 697 A. Pineapple Incident (数学)
- Codeforces Round #362 (Div. 2)(A~D))
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #173 (Div. 2) A.Bit++
- CString转换指针
- 有1000亿条记录,每条记录由url,ip,时间组成,设计一个系统能够快速查询以下内容(程序设计题)
- 指针的相关知识及注意点(如何避免野指针)
- 设计模式中类的关系
- QT中界面设计遇到的问题
- Codeforces Round #362 (Div. 2) A. Pineapple Incident
- 华为OJ——查找输入整数二进制中1的个数
- pyqt 点点滴滴
- JavaScript 提高性能的几个知识点总结
- android.graphics.Rect类的详解
- 华为OJ——DNA序列
- scala基础1-基本表达式
- 复杂链表的复制 java
- 华为OJ——MP3光标位置