zoukankan      html  css  js  c++  java
  • Codeforces Round #362 (Div. 2) A 水也挂

    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, t + s, t + s + 1, t + 2s, t + 2s + 1,   给你t,s ,x 判断x是否为序列中的值

    题解: 水题也挂终测   靠hack 上分

     1 #include<bits/stdc++.h>
     2 #define ll __int64
     3 #define mod 1e9+7
     4 #define PI acos(-1.0)
     5 #define bug(x) printf("%%%%%%%%%%%%%",x);
     6 using namespace std;
     7 int t,s,x;
     8 int main()
     9 {
    10     scanf("%d %d %d",&t,&s,&x);
    11     if(t==x)
    12     {
    13     cout<<"YES"<<endl;
    14     return 0;
    15     }
    16     if(x<t||x<t+s)
    17     {
    18         cout<<"NO"<<endl;
    19         return 0;
    20     }
    21     x=x-t;
    22     if(x%s==1||x%s==0)
    23     {
    24         cout<<"YES"<<endl;
    25         return 0;
    26     }
    27     cout<<"NO"<<endl;
    28     return 0;
    29 }
  • 相关阅读:
    【GPS】Android O平台如何设置SUPL地址,以及GPS三个配置文件的优先级分析
    【GPS】gps.conf文件解读
    【GPS】SAP测试GPS模块拿不到sensor数据
    Linux系统安装Samba共享服务器详解及安装配置
    CentOS 6.5 编译安装 LNMP环境
    linux禁止root用户直接登录
    Linux下安装配置日志服务器
    Windows系统安装Oracle 11g客户端
    Linux系统zabbix_agentd客户端安装与配置
    Redhat6.5——解决yum功能不能正常使用
  • 原文地址:https://www.cnblogs.com/hsd-/p/5674680.html
Copyright © 2011-2022 走看看