Victor and Machine

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)

Total Submission(s): 240    Accepted Submission(s): 134

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
 
Source
 

/* ***********************************************
Author :CKboss
Created Time :2015年08月22日 星期六 21时57分18秒
File Name :HDOJ5417.cpp
************************************************ */ #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map> using namespace std; int x,y,w,n; int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout); while(cin>>x>>y>>w>>n)
{
int X=x;
int time=0;
for(int i=2;i<=n;i++)
{
if(time+w<=x)
{
time+=w;
}
else
{
time=x;
time+=y;
x=x+y+X;
}
}
cout<<time<<endl;
} return 0;
}

HDOJ 5417 Victor and Machine 水的更多相关文章

  1. hdoj 5417 Victor and Machine

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

  2. HDU 5417 Victor and Machine

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5417 Problem Description Victor has a machine. When t ...

  3. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  4. HDOJ 5418 Victor and World 状压DP

    水状压DP Victor and World Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/131072 K (Java ...

  5. HDOJ/HDU 2560 Buildings(嗯~水题)

    Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, ...

  6. HDOJ(HDU) 1859 最小长方形(水题、、)

    Problem Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内 ...

  7. hdoj 4272 LianLianKan 数据太水

    LianLianKan Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  8. HDU 5670 Machine 水题

    Machine 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5670 Description There is a machine with m(2 ...

  9. hdu-5670 Machine(水题附上java代码)

    题目链接: Machine  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描 ...

随机推荐

  1. 【LeetCode】-- 260. Single Number III

    问题描述: https://leetcode.com/problems/single-number-iii/ 在一个数组里面,只有两个元素仅出现过1次,其余都出现过两次.找出出现仅一次的那两个(a, ...

  2. Linux+Apache+PHP+MySQL服务器环境配置(CentOS篇)

    1.配置php.ini vi /etc/php.ini 2.配置apache 先给需要配置的文件做个备份 cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/h ...

  3. 1B课程笔记分享_StudyJams_2017

    课程1B 概述 课程1B主要讲解了Android UI的ViewGroups(视图组).LinearLayout(线性布局).RelativeLayout(相对布局),Portrait Mode(竖屏 ...

  4. CSS——行内元素的margin与padding

    行内元素: 1.margin:0 20px:只可以定义左右. 2.pading:20px 20px 20px 20px:上下左右都有效 例如span: <!DOCTYPE html> &l ...

  5. ASP.NET MVC 二维码生成(ThoughtWorks.QRCode)

    原文地址http://www.cnblogs.com/jys509/p/4592539.html

  6. 我的liunx开发环境的配置之路

    相信有不少人和我一样,虽然是做纯linux开发,但并不排斥windows,并且喜欢在windows下面的使用各种好用的工具来让linux的编程工作变得更加方便.实际上每一个系统都有他的过人支持,win ...

  7. (转) Arcgis for Javascript实现两个地图的联动

    http://blog.csdn.net/gisshixisheng/article/details/40127895 今天在看天地图的时候,有一个多时相的地图显示功能,感觉很好玩,作为技术控的我晚上 ...

  8. (转)Hibernate的优化方案

    http://blog.csdn.net/yerenyuan_pku/article/details/70768603 HQL优化 使用参数绑定  使用绑定参数的原因是让数据库一次解析SQL,对后续的 ...

  9. django-Celery分布式队列简单使用

    介绍: Celery 是一个简单.灵活且可靠的,处理大量消息的分布式系统,并且提供维护这样一个系统的必需工具. 它是一个专注于实时处理的任务队列,同时也支持任务调度. worker:是一个独立的进程, ...

  10. 结果缓冲区 resbuf具体用法

    struct resbuf *rb; rb=acutBulidlist(RTSTR,text(), rtpoint,,,,,) 创建圆用法. acdbEntGet 返回结果缓冲区  然后 rb-> ...