YTU OJ 3315: Pineapple Incident

版权声明:欢迎大佬批评指正!O(∩_∩)O https://blog.csdn.net/wyh1618/article/details/82691833

3315: Pineapple Incident

题目描述

泰德有一个菠萝。这种菠萝能够像斗牛犬一样吠叫!在时间t(以秒为单位),它第一次吠叫。然后每隔s秒后,它以1秒的间隔吠叫两次。因此它在时间t,t + s,t + s + 1,t + 2 s,t + 2 s + 1等时吠叫。 

Barney早上醒来想要吃菠萝,但是当它吠叫时他不能吃。Barney计划在时间x(以秒为单位)吃它,所以他让你告诉他当时是否会吠叫。 

输入

一行包含三个整数,t,s,x(0<=t,x<=10^9,2<=s<=10^9) 

输出

如果菠萝在时间x吠叫,打印“YES”,否则打印“NO". 

#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main()
{
    long long int a,b,c;
    scanf("%I64d%I64d%I64d",&a,&b,&c);
    if(a>c)
    {
        printf("NO\n");
    }
    if(a==c)
    {
        printf("YES\n");
    }
    if(a<c)
    {
        if(((c-a)%b==0)||((c-a)%b==1)&&(c-a)!=1)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}

 

猜你喜欢

转载自blog.csdn.net/wyh1618/article/details/82691833