Codeforces Round #362 (Div. 2) A 水也挂
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 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, t + s, t + s + 1, t + 2s, t + 2s + 1, 给你t,s ,x 判断x是否为序列中的值
题解: 水题也挂终测 靠hack 上分
#include<bits/stdc++.h>
#define ll __int64
#define mod 1e9+7
#define PI acos(-1.0)
#define bug(x) printf("%%%%%%%%%%%%%",x);
using namespace std;
int t,s,x;
int main()
{
scanf("%d %d %d",&t,&s,&x);
if(t==x)
{
cout<<"YES"<<endl;
return ;
}
if(x<t||x<t+s)
{
cout<<"NO"<<endl;
return ;
}
x=x-t;
if(x%s==||x%s==)
{
cout<<"YES"<<endl;
return ;
}
cout<<"NO"<<endl;
return ;
}
Codeforces Round #362 (Div. 2) A 水也挂的更多相关文章
- Codeforces Round #365 (Div. 2) A 水
A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #362 (Div. 2) C. Lorenzo Von Matterhorn (类似LCA)
题目链接:http://codeforces.com/problemset/problem/697/D 给你一个有规则的二叉树,大概有1e18个点. 有两种操作:1操作是将u到v上的路径加上w,2操作 ...
- Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)
A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...
- Codeforces Round #408 (Div. 2)(A.水,B,模拟)
A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...
- #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 ...
- Codeforces Round #394 (Div. 2)A水 B暴力 C暴力 D二分 E dfs
A. Dasha and Stairs time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #169 (Div. 2) A水 B C区间更新 D 思路
A. Lunch Rush time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #337 (Div. 2) A水
A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #316 (Div. 2) A 水
A. Elections time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
随机推荐
- vue中created、mounted等方法整理
- Drupal相关网站推荐
http://nodeone.se/ drupal7安装过程中,如果选择简体中文,到导入翻译时出现错误,原因是执行超时了. 方法一: 修改php.ini文件:memory_limit = 256M ( ...
- let和const在es6中的异同点
let和const这两个都是声明一个变量或函数的方法与var差不太多的效果 let的声明在for循环中,当你定义的是多少,最后你的值就是多少开始的,它只进行一次循环,不会像var那样去一遍一遍的去遍历 ...
- SpringBoot AOP综合例子
完整源码:https://github.com/947133297/cgLibDemo 通过AOP来便捷地输出日志,能更加方便排查系统的bug,这个例子中简单输出自定义文件和函数执行时的参数,函数要不 ...
- thinkphp 3.2.3 - App.class.php 解析
class App { public static function init() { load_ext_file(COMMON_PATH); // { // /home/www/www.domain ...
- 科学计算库Numpy——数值计算
矩阵 求和 乘积 最大值和最小值 最大值和最小值的位置 平均数 标准差 方差 限制 四舍五入
- GoF23种设计模式之创建型模式之建造者模式
一.概述 将一个复杂对象的构建与其表示分离开来,使得同样的构建过程可以创建不同的表示. 二.适用性 1.当创建复杂对象的算法应该独立于该对象的组成部分以及它们的装配方式的时候. 2.当构造过程必须允许 ...
- Python中列表的深浅拷贝
copy_lst = [ ('py对象三要素',), ('== 比较运算符',), ('is 身份运算符',), ('小数据池',), ('列表的浅拷贝',), ('列表的深拷贝',), ] py对象 ...
- 单片机入门学习笔记6:新唐单片机N76E003
学习新唐单片机是从2018年3月开始的,之前一点也不懂这一块单片机,之后脉络变的越来越清晰. 由于N76E003档次太低,新塘科技官方的管脚配置,芯片选型……都没有这一块芯片,资料唯独只有:芯片的数据 ...
- GNU中的关键字typeof
如果你是 C++ 程序员,应该接触过 C++11 里的 decltype 操作符,它的作用是自动推导表达式的数据类型,以解决泛型编程中有些类型由模板参数决定而难以(甚至不可能)表示的问题.其实这个特性 ...