Codeforces Round #362 (Div. 2)->A. Pineapple Incident
1 second
256 megabytes
standard input
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.
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.
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.
3 10 4
NO
3 10 3
YES
3 8 51
YES
3 8 52
YES
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的更多相关文章
- 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 ...
- Codeforces Round #362 (Div. 2) A 水也挂
A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Round #362 (Div. 2)
闲来无事一套CF啊,我觉得这几个题还是有套路的,但是很明显,这个题并不难 A. Pineapple Incident time limit per test 1 second memory limit ...
- Codeforces Round #362 (Div. 2) C. Lorenzo Von Matterhorn (类似LCA)
题目链接:http://codeforces.com/problemset/problem/697/D 给你一个有规则的二叉树,大概有1e18个点. 有两种操作:1操作是将u到v上的路径加上w,2操作 ...
- #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 ...
- 【转载】【树形DP】【数学期望】Codeforces Round #362 (Div. 2) D.Puzzles
期望计算的套路: 1.定义:算出所有测试值的和,除以测试次数. 2.定义:算出所有值出现的概率与其乘积之和. 3.用前一步的期望,加上两者的期望距离,递推出来. 题意: 一个树,dfs遍历子树的顺序是 ...
- 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 ...
- Codeforces Round #362 (Div. 2) B 模拟
B. Barnicle time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- 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 ...
随机推荐
- Cocos2d-x 3.x的Windows Phone 8工程
Cocos2d-x 3.x中我们使用的Cocos2d-x 3.2,它提供了Windows Phone 8平台的支持.下面我们介绍一下在Cocos2d-x 3.2中如何生成Cocos2d-x的Windo ...
- Java获取操作系统信息
今天在看jdk的demo时候发现java获取系统操作系统的一些信息,例如内存使用情况,于是自己也想研究研究! 百度一番,发现有2种方法! 1.sun自带的API 2.第三方jar(Sigar) 先 ...
- linux install mpi4py
Downloading The MPI for Python package is available for download at the project website generously h ...
- POJ 2407 Relatives
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13920 Accepted: 6965 Description Give ...
- MVC5_学习笔记_1_CodeFirst
MVC5_EF6_1/* GitHub stylesheet for MarkdownPad (http://markdownpad.com) *//* Author: Nicolas Hery - ...
- ROS
1 SSH 为什么我用 ssh 用户名 就不行,用 ssh xxx.xxx.xxx.xxx -l 用户名 就可以了呢 2 SCP 传送文件到另一个IP 用法: scp xxx root@xx.x ...
- 命名空间 和 class_exist() 问题
#namespace_test_1.php <?php namespace namespace_test_1; class test { const NAMESPACE = 'namespace ...
- javascript "\" 在字符串里的是转义的意思
"\n" 在字符串里是换行的意思 alert("dfdsad\ndfsdf"); //有换行 alert("abc\de"); // ...
- DML,DDL,DCL,DQL的区别
DML 英文缩写 DML = Data Manipulation Language,数据操纵语言,命令使用户能够查询数据库以及操作已有数据库中的数据的计算机语言.具体是指是UPDATE更新.INS ...
- Linux 使用退格键时出现^H解决方法
当我们再和脚本交互的时候,在终端上输错了内容,使用退格键,屏幕上会出现乱码,比如 ^H.^H不是H键的意思,是backspace. 主要是当你的终端backspace有问题的时候才需要设置. 解决方法 ...