题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5417

Problem Description
Victor has a machine. When the machine starts up, it will pop out a ball immediately. After that, the machine will pop out a ball every w seconds. However, the machine has some flaws, every time after x seconds of process the machine has to turn off for y seconds for maintenance work. At the second the machine will be shut down, it may pop out a ball. And while it's off, the machine will pop out no ball before the machine restart.

Now, at the 0 second, the machine opens for the first time. Victor wants to know when the n-th ball will be popped out. Could you tell him?

 
Input
The input contains several test cases, at most 100 cases.

Each line has four integers x, y, w and n. Their meanings are shown above。

1≤x,y,w,n≤100.

 
Output
For each test case, you should output a line contains a number indicates the time when the n-th ball will be popped out.
 
Sample Input
2 3 3 3
98 76 54 32
10 9 8 100
 
Sample Output
10
2664
939
题意:

Victor有一个机器,这个机器每次开启的瞬间会弹出一个小球,之后每隔ww秒会弹出一个小球。因为机器不是很完善,该机器每开启xx秒就得关闭yy秒进行调整,在机器关闭的瞬间可能会有小球弹出,关闭之后一直到下一次开启之前都不会有小球弹出。

00时刻,机器第一次开启,Victor想要知道第nn个小球弹出的时刻,你能够告诉他吗?
大水题,模拟。
 #include <iostream>
using namespace std; int main()
{
int n,w,x,y;
while (cin>>x>>y>>w>>n)
{
int t=,tt=;//tt记录离刚开机多长时间
n--;
while (n>)
{
tt+=w;
if (tt<x)
{
n--;
t+=w;
}
else if (tt==x)
{
n--;
t+=w;
if (n>)
{
tt=;
t+=y;
n--;
}
}
else
{
t+=w+x+y-tt;
tt=;
n--;
}
}
cout <<t<<endl;
}
return ;
}

HDU 5417 Victor and Machine的更多相关文章

  1. HDOJ 5417 Victor and Machine 水

    Victor and Machine Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Othe ...

  2. hdoj 5417 Victor and Machine

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5417 水题,一开始题目读错了做了好久,每次停工以后都是重新计时. 需要注意的是,先除后乘注意加括号 # ...

  3. ACM: HDU 5418 Victor and World - Floyd算法+dp状态压缩

    HDU 5418 Victor and World Time Limit:2000MS     Memory Limit:131072KB     64bit IO Format:%I64d & ...

  4. HDU 5418 Victor and World 允许多次经过的TSP

    题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5418 bestcoder(中文): http://bestcoder.hdu.edu.cn ...

  5. HDU 5418 Victor and World(状压DP+Floyed预处理)

    Victor and World Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/131072 K (Java/Other ...

  6. HDU 5421 Victor and String

    Victor and String Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on HDU. Orig ...

  7. HDU 5420 Victor and Proposition

    Victor and Proposition Time Limit: 6000ms Memory Limit: 524288KB This problem will be judged on HDU. ...

  8. HDU 4052 Adding New Machine (线段树+离散化)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4052 初始给你w*h的矩阵,给你n个矩形(互不相交),按这些矩形尺寸把初始的矩形扣掉,形成一个新的'矩 ...

  9. HDU 5067-Harry And Dig Machine(DFS)

    Harry And Dig Machine Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

随机推荐

  1. IIC 概述之24c系列存储器内存分析

    IIC 型号     容量      器件/业面寻址字节                   可寻址位       模块 24C01   128B      (1010)(A2)(A1)(A0)(0或 ...

  2. Python 变量有效范围

  3. Linux下关闭node应用

    今天在折腾用node接入微信公众号时,碰到了node应用启动后卡死退出,需要找出该进程关闭的问题,由于对shell脚本不是很熟悉,记录如下: 我们在用npm start启动应用后,通常要关闭时,ctr ...

  4. win7系统64位"禁用驱动程序签名强制"如何设置?

    换了Win7系统64位旗舰版的朋友是不是都发现了一点,以前32位Win7系统用的好好的小程序小应用,一下子就装不上了.这是由于Win7系统64位系统对于未有认证签名的驱动程序进行了限制安装,而大部分小 ...

  5. NGINX实现IF语句里的AND,OR多重判断

    原理 就是用SET变量进行. AND 就用变量叠加,OR就用0或1切换. nginx的配置中不支持if条件的逻辑与/逻辑或运算 ,并且不支持if的嵌套语法,我们可以用变量的方式来实现: 首先是伪代码( ...

  6. url的三个js编码函数escape(),encodeURI(),encodeURIComponent()简介

    url的三个js编码函数escape(),encodeURI(),encodeURIComponent()简介 2014年10月12日 16806次浏览 引子 浏览器URl地址,上网一定会用到,但是浏 ...

  7. Powershell ForEach-Object 循环

    Powershell管道就像流水线,对于数据的处理是一个环节接着一个环节,如果你想在某一环节对流进来的数据逐个细致化的处理,可是使用ForEach-Object,$_ 代表当前的数据. 对管道对象逐个 ...

  8. How to run Tomcat without root privileges? 常规用户使用tomcat的80端口

    How to run Tomcat without root privileges? 1. The best way is to use jsvc, available as part of the  ...

  9. C#使用WebKitBrowser.dll填坑记

    .Net 自带的 Webbrowser 有着太多的平台限制.对于用户体验之上的今天,这无疑是一个噩梦, 然后就开始找 .Net下的WebKitBrowser.dll (后面提供下载) 从开源网站下到程 ...

  10. Bloom Filter 算法具体解释

    Bloom Filter 算法 Bloom filter是由Burton Bloom 在1970年提出的,其后在P2P上得到了广泛的应用.Bloom filter 算法可用来查询某一数据是否在某一数据 ...