http://codeforces.com/problemset/problem/697/A
题意:
判断猫在这个时间点会不会叫(是不是猫?),一次叫两声。
键入数据提示:
开始叫的时间 t;过 s 秒后再叫(记得是两次);判断的时间点
思路:
给定的是两个等差数列,无奈的就是自己保证了 a2>0 但是没考虑 a1 的正负!
Code:
#include<stdio.h>
#include<cstring>
const int MYDD=1103;
int main() {
int t,s,x;
while(scanf("%d%d%d",&t,&s,&x)!=EOF) {
double a1,a2;
// if(x==t+s) {
// puts("YES");
// continue;
// }
//
a1=(x-t)*1.0/(s*1.0);
a2=(x-t-1)*1.0/(s*1.0);
if((a1==(int)a1&&a1>=0)||(a2==(int)a2&&a2>0)) puts("YES");//会叫 miaomiao 的
else puts("NO");
}
return 0;
}