Codeforces 697A. Pineapple Incident (模拟)
2016-07-16 16:21
351 查看
题目链接
简单题意
狗会在t时刻叫一声,之后每过s时间,他会叫两声,即在t+k*s和t+k*s+1时刻叫,给出一个时刻x,问狗会不会在x时刻叫思路
当(x-t)%s ==0 或==1时叫,第一次特判,其他时间都不叫。代码
#include <bits/stdc++.h> using namespace std; int main (){ int t,s,x; cin >> t >> s >>x; if(x == t){puts("YES"); return 0;} if(x < s+t && x != t){puts("NO"); return 0;} x -= t; if(x < 0) {puts("NO");return 0;} x %= s; if(x ==0 || x == 1) puts("YES"); else puts("NO"); return 0; }
相关文章推荐
- Android短信和拨打电话
- Android应用层使用共享内存机制进行进程间交换数据
- APP开发实战85-帧动画
- Android的UI界面
- Android Design Support Library(一):FloatingActionButton、TextInputLayout、TextInputEditText简单用法
- 九点(九宫格)式手势解锁自定义view
- Android Studio中“非法字符\\65279,Error:(1, 10) 错误: 需要class, interface或enum”
- 给EventBus增加订阅收到消息提醒,用AndroidStudio重新打包成Jar文件
- 判断用户是安卓还是ios的php代码
- Android GridView设置宽高,即item宽度高度
- 各个平台支持的Cocos2d-x最大纹理尺寸
- swift 在函数内改变函数外的值(元组+inout)
- Android Material 之CoordinatorLayout、AppBarLayout、CollapsingToolbarLayout、Toolbar 等的说明和使用
- Android repo git 分支切换管理
- 判断是否是手机端打开的页面
- Swift快速集成函数使用篇(生成二维码)
- Unable to resolve project target 'android-21'
- Android M 新的运行时权限开发者需要知道的一切
- 慕课网实战—《用组件方式开发 Web App全站 》笔记五-折线图组件开发
- Android进阶——Preference详解之Preference系的基本应用(三)