题目链接:点这儿

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. PIC单片机之时钟设置

    PIC单片机之时钟设置 http://blog.csdn.net/superanters/article/details/8541650 内部时钟和外部时钟? PIC单片机有许多型号可以设置成 用外部 ...

  2. hihoCoder 1133 二分·二分查找之k小数(TOP K算法)

    #1133 : 二分·二分查找之k小数 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 在上一回里我们知道Nettle在玩<艦これ>,Nettle的镇守府有很 ...

  3. pat 团体天梯赛 L2-002. 链表去重

    L2-002. 链表去重 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 给定一个带整数键值的单链表L,本题要求你编写程序,删除 ...

  4. 【AtCoder Regular Contest 076 F】Exhausted (贪心)

    Description 机房里有M台电脑排成一排,第i台电脑的坐标是正整数i. 现在有N个OIer进入了机房,每个OIer需要一台电脑来学tui习ji,同时每个OIer对自己电脑所处的坐标范围有一个要 ...

  5. C#可选参数与具名参数

    可选参数 static void test1() { func1("A"); func1(); Console.ReadKey(); } ) { Console.WriteLine ...

  6. sql2008安装时 重新启动计算机 失败

    原文发布时间为:2010-11-02 -- 来源于本人的百度文章 [由搬家工具导入] sql2008安装时 重新启动计算机 失败解决方法:regedit 运行 打开注册表,找到HKEY_LOCAL_M ...

  7. 自定义及发布一个webservice服务

    自定义及发布一个webservice服务    - 声明 某个业务服务为webservice服务       通过@webservice 注解来声明    - 发布webservice服务       ...

  8. 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---31

    以下为阅读<Linux命令行与shell脚本编程大全 第3版>的读书笔记,为了方便记录,特地与书的内容保持同步,特意做成一节一次随笔,特记录如下:

  9. shell文本过滤编程(一):grep和正则表达式【转】

    转自:http://blog.csdn.net/shallnet/article/details/38799739 版权声明:本文为博主原创文章,未经博主允许不得转载.如果您觉得文章对您有用,请点击文 ...

  10. hdu 3986(最短路变形好题)

    Harry Potter and the Final Battle Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65536/6553 ...