题目链接:点这儿

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. button的默认type居然是submit

    今天使用了html中的button标签,用js写了一点代码来完成onclick实践,当我点下它的时候,它不仅执行了我写的function,还把表单给提交了,一查它的button居然是sumbit. 然 ...

  2. WS-*协议栈及相关概念

    1. 什么是WS-Security? WS-Security 是一个 SOAP 的扩展,它提供了对 SOAP 消息的认证和加密. 在介绍 WS-Security 之前,我们有必要了解一下 WS-Sec ...

  3. Ubuntu安装opencv with cuda

    Ubuntu安装opencv with cuda 为了运行dense flow真是折腾啊,下面网址是教程 http://blog.aicry.com/ubuntu-14-04-install-open ...

  4. kubernetes-dashboard

    1.导入kubernetes-dashboard 镜像 [root@node1 DNS]# docker load < kube-dashboard.tar 6bc90c4dba69: Load ...

  5. Vue中slot内容分发

    <slot>元素是一个内容分发API,使用多个内容插槽时可指定name属性 <!DOCTYPE html> <html> <head> <meta ...

  6. python(1)-- 变量类型

    常规: Python有五个标准的数据类型: Numbers(数字):数字数据类型用于存储数值.他们是不可改变的数据类型,这意味着改变数字数据类型会分配一个新的对象.String(字符串):由数字.字母 ...

  7. DataSet导出Excel,比以往的方法导出的Excel外观更加好看

    原文发布时间为:2010-06-21 -- 来源于本人的百度文章 [由搬家工具导入] ======目前方法=========== #region 生成Excel/// <summary>/ ...

  8. 控制台或Winform程序中如何编码或解码Server.URLEncode

    原文发布时间为:2010-07-10 -- 来源于本人的百度文章 [由搬家工具导入] 在Asp.net中可以使用Server.HTMLEncode和Server.URLEncode 将文本或URL的特 ...

  9. 【shell入门】Shell用法

    参考:http://www.cnblogs.com/Lynn-Zhang/p/5758287.html 1.sh/bash/csh/Tcsh/ksh/pdksh等shell的区别 sh(全称 Bour ...

  10. poj 1637 Sightseeing tour 混合图欧拉回路 最大流 建图

    题目链接 题意 给定一个混合图,里面既有有向边也有无向边.问该图中是否存在一条路径,经过每条边恰好一次. 思路 从欧拉回路说起 首先回顾有向图欧拉回路的充要条件:\(\forall v\in G, d ...