题目链接:点这儿

Victor and Machine

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

Total Submission(s): 87    Accepted Submission(s): 48

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

题意:有中文版的。就不多说了

分析:机器执行关闭为一回合。计算出每回合能弹出多少个小球。然后处理一下不是执行/关闭的情况就OK了。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define ll long long
const double eps = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007; int main ()
{
int x,y,w,n;
while (scanf ("%d%d%d%d",&x,&y,&w,&n)==4)
{
int t;
if (x < w)
t = (x+y)*(n-1);
else
{
int a=x/w+1;
if (n%a==0)
t = (n/a)*(x+y)-y-x%w;
else
t = (n/a)*(x+y)+(n%a-1)*w;
}
printf ("%d\n",t);
}
return 0;
}

hdu5417(BC)的更多相关文章

  1. 欧拉(BC)

    输入样例 1 1 2 1 3 2 输出样例 2 2 2f(x)打表找规律的 fx=x+1,fn(x)=x+n+1;然后用欧拉公式 #include <iostream> #include ...

  2. Business Component(BC)和Business Object(BO)

    Siebel应用架构的一个成功的地方就是在应用里引入了BC,BO的概念,从而使得几千张关系数据表能够按照业务的含义组织成业务对象,对于业务人员而言具有了业务上的含义,而不仅仅是从技术人员的观点来对待数 ...

  3. PHP 7 值得期待的新特性(上)

    这是我们期待已久的 PHP 7 系列文章的第一篇. 或许你已经知道了,我在 PHP 5.0.0 时间轴 提的 RFC (Request For Comments)通过了, PHP 7 成为 PHP 下 ...

  4. 几款开源ESB总线的比较(转)

    现有的开源ESB总线中,自从2003年第一个开源总线Mule出现后,现在已经是百花争鸣的景象了.现在我就对现有的各种开源ESB总线依据性能.可扩展性.资料文档完整程度以及整合难易程度等方面展开. CX ...

  5. java加密算法入门(一)-算法概念及单向加密

    说起加密,我的第一印象就是电视剧各种密码本破解解密的场景,这两天在看加密相关的东西,做下笔记以便以后查看,也提供给大家个参考. 本文是java加密的第一篇,主要讲述下消息编码Base64以及简单的消息 ...

  6. java面试基础题(三)

    程序员面试之九阴真经 谈谈final, finally, finalize的区别: final:::修饰符(关键字)如果一个类被声明为final,意味着它不能再派生出新的子类,不能作为父类被继承.因此 ...

  7. 2017-2018-1 20155331 课下测试(ch10)

    2017-2018-1 20155331 课下测试(ch10) 假设下面代码中的foobar.txt中有6个ASCII字母,程序的输出是(A) Image 7.png A . c = f B . c ...

  8. .NET 微服务 2 架构设计理论(一)

    SOA体系架构 面向服务的体系结构 (SOA) ,通过将应用程序分解为多个服务(通常为 HTTP 服务,WCF服务等),将其分为不同类型(例如子系统或层),从而来划分应用程序的结构. 微服务源自 SO ...

  9. ML面试1000题系列(81-90)

    本文总结ML面试常见的问题集 转载来源:https://blog.csdn.net/v_july_v/article/details/78121924 81.已知一组数据的协方差矩阵P,下面关于主分量 ...

随机推荐

  1. PHP共享内存的应用shmop系列

    简单的说明 可能很少情况会使用PHP来操控共享内存,一方面在内存的控制上,MC已经提供了一套很好的方式,另一方面,自己来操控内存的难度较大,内存的读写与转存,包括后面可能会用到的存储策略,要是没有一定 ...

  2. Pointcut is not well-formed: expecting 'identifier' at character position 0 ^ || Pointcut is not well-formed: expecting ')' at character position 11 ^

    错误提示: 解决方法1:指定execution 在执行目标方法之前指定execution 解决方法2:可能是execution写错了.请仔细检查. 其他——execution参数设置(带问好的可以不配 ...

  3. P2846 [USACO08NOV]光开关Light Switching

    题目描述 Farmer John tries to keep the cows sharp by letting them play with intellectual toys. One of th ...

  4. Codeforces Round #440(Div.2)

    一句话题意: A:给出两个长为\(n\),\(m\)的的数组,每个数在\(1\)到\(9\)之间,求出一个最小的数使得至少有一位出现在一个数组中,且至少有一位出现在另一个数组中.\(n,m\leq9\ ...

  5. 【VBA】随机数

    [说明] 随机数.生成2个随机数m.n,取值范围为1~R.1~C Randomize m = )) + ) ' 1~R Random Int Randomize n = )) + ) ' 1~C Ra ...

  6. C++ vector 的 begin()、end()、front()、back() 区别

    STL中实现源码可见:http://www.cplusplus.com/reference/vector/vector/begin/ 一.begin函数 函数原型: iterator begin(); ...

  7. [agc014d] Black and White Tree(玄学树D)

    Description 有一颗n个点的树,刚开始每个点都没有颜色. Alice和Bob会轮流对这棵树的一个点涂色,Alice涂白,Bob涂黑,Alice先手. 若最后存在一个白点,使得这个白点所有相邻 ...

  8. Array拼接字符串

    原文发布时间为:2011-01-12 -- 来源于本人的百度文章 [由搬家工具导入] Array拼接字符串本来就是一种投机取巧的无聊玩意,来源是IE6对字符串的+实现错误一般情况下,如果是语义性的字符 ...

  9. Java中的内存机制及管理

    1. Java根据虚拟机以及平台的版本不同而在内存中开辟不同大小的内存,通常不会关注这个大小. 2. 程序中的对象存储在内存的堆(heap)中 3. 程序中的方法和局部变量存储在内存的栈(Stack) ...

  10. 转载——Java与WCF交互(一)补充:用WSImport生成WSDL的Java客户端代码

    在<Java与WCF交互(一):Java客户端调用WCF服务>一文中,我描述了用axis2的一个Eclipse控件生成WCF的Java客户端代理类,后来有朋友建议用Xfire.CXF,一直 ...