博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 5417 Victor and Machine
阅读量:5327 次
发布时间:2019-06-14

本文共 1540 字,大约阅读时间需要 5 分钟。

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。
1x,y,w,n100.
 

 

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

  题意:一台机器每W分钟吐出一个球,但是它每隔x分要停y分钟。它每次开始时要吐出一个球。求吐出第n个球的时间。

 我们先算每x分钟能吐出多少个球,用n除每分钟吐出的球,就能知道机器要停机次,然后就简单了。

  

1 #include
2 #include
3 using namespace std; 4 int main() 5 { 6 int n,w,x,y,ans,t; 7 while (~scanf("%d%d%d%d",&x,&y,&w,&n)) 8 { 9 t=x/w+1;10 if (n%t==0)11 {12 ans=(n/t-1)*(x+y);13 ans+=(t-1)*w;14 }15 else16 {17 ans=(n/t)*(x+y);18 ans+=(n%t-1)*w;19 }20 printf("%d\n",ans);21 }22 }

 

转载于:https://www.cnblogs.com/pblr/p/4751248.html

你可能感兴趣的文章
较快的maven的settings.xml文件
查看>>
Git之初体验 持续更新
查看>>
Exception in thread "AWT-EventQueue-0" java.lang.IllegalThreadStateException
查看>>
随手练——HDU 5015 矩阵快速幂
查看>>
Maven之setting.xml配置文件详解
查看>>
SDK目录结构
查看>>
malloc() & free()
查看>>
HDU 2063 过山车
查看>>
高精度1--加法
查看>>
String比较
查看>>
Django之Models
查看>>
CSS 透明度级别 及 背景透明
查看>>
Linux 的 date 日期的使用
查看>>
PHP zip压缩文件及解压
查看>>
SOAP web service用AFNetWorking实现请求
查看>>
Java变量类型,实例变量 与局部变量 静态变量
查看>>
mysql操作命令梳理(4)-中文乱码问题
查看>>
Python环境搭建(安装、验证与卸载)
查看>>
一个.NET通用JSON解析/构建类的实现(c#)
查看>>
Windows Phone开发(5):室内装修 转:http://blog.csdn.net/tcjiaan/article/details/7269014
查看>>