hdu 5417 Victor and Machine(模拟)
2015-08-23 09:56
246 查看
题意:
Victor有一个机器,这个机器每次开启的瞬间会弹出一个小球,之后每隔www秒会弹出一个小球。因为机器不是很完善,该机器每开启xxx秒就得关闭yyy秒进行调整,在机器关闭的瞬间可能会有小球弹出,关闭之后一直到下一次开启之前都不会有小球弹出。0时刻,机器第一次开启,Victor想要知道第nnn个小球弹出的时刻,你能够告诉他吗?
解析:
直接模拟就好了。mymy codecode
[code]#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int x, y, w, n; int cal() { int cnt = 0, time = 0, ans = 0; while(true) { for(int i = 0; i <= x; i += w) { cnt++; if(cnt >= n) return ans; ans += w; } ans = (x + y) * (++time); } return ans; } int main() { while(scanf("%d%d%d%d", &x, &y, &w, &n) != EOF) { printf("%d\n", cal()); } return 0; }
相关文章推荐
- Win + D 和 Win + M的区别
- 汉诺塔问题
- Java 反射:Class类,动态加载类获取方法和成员变量构造信息,方法反射的基本操作,集合泛型的本质
- 571B. Minimization(Codeforces Round #317)
- POJ 1988 Cube Stacking 并查集
- A1024. Palindromic Number (25)
- 《JavaScript DOM编程艺术》
- 洛谷1219 八皇后 解题报告
- C# 格式化字符串
- Andriod学习系列之(四)Intent初涉
- 【十一】运算符重载(下)
- C# 格式化字符串
- WordPress网站设置搜索引擎关键词和描述
- C语言基础知识之(二):分支
- 阿里淘宝知名工程师
- Effective C++ 条款15 在资源管理类中提供对资源的原始访问
- Apache Shiro 开源权限框架
- 万网空间PHP网页设置SMTP发送评论功能
- 集合类说明及区别
- kafka笔记(PacktPub.Apache.Kafka)