题目传送门

题意:有中文版

分析:首先要知道机器关闭后,w是清零的。所以一次(x + y)的循环弹出的小球个数是固定的,为x / w + 1,那么在边界时讨论一下就行了

收获:这种题目不难,理解清楚题意,yy出可行的解法总能做出来

代码:

/************************************************
* Author :Running_Time
* Created Time :2015-8-22 18:55:05
* File Name :A.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7; int main(void) {
int x, y, w, n;
while (scanf ("%d%d%d%d", &x, &y, &w, &n) == 4) {
int cnt = 0;
int t = 0;
int a = x / w + 1;
while (cnt + a <= n) {
cnt += a;
if (cnt == n) {
t += (a - 1) * w; break;
}
else if (cnt == n - 1) {
t += x + y; break;
}
else t += (x + y);
}
if (cnt == n || cnt == n - 1) {
printf ("%d\n", t); continue;
}
cnt++; //忘写,WA一次
while (cnt < n) {
t += w;
cnt++;
}
printf ("%d\n", t);
} return 0;
}

  

构造 BestCoder Round #52 (div.2) 1001 Victor and Machine的更多相关文章

  1. TSP+Floyd BestCoder Round #52 (div.2) 1002 Victor and Machine

    题目传送门 题意:有中文版的 分析:(出题人的解题报告)我们首先需要预处理出任意两个国家之间的最短距离,因为数据范围很小,所以直接用Floyd就行了.之后,我们用f[S][i]表示访问国家的情况为S, ...

  2. 判素数+找规律 BestCoder Round #51 (div.2) 1001 Zball in Tina Town

    题目传送门 /* 题意: 求(n-1)! mod n 数论:没啥意思,打个表能发现规律,但坑点是4时要特判! */ /***************************************** ...

  3. BestCoder Round #52 (div.1)

    这周六BC和CF又差点打架,精力不够啊...结果打BC没起来,就看了一眼题跑了...今天早上补补吧,(因为今天晚上还要打UER= =) 先放官方题解: 1000 Victor and Machine ...

  4. BestCoder Round #52 (div.2) HDU 5418 Victor and World (DP+状态压缩)

    [题目链接]:pid=5418">click here~~ [题目大意]: 问题描写叙述 经过多年的努力,Victor最终考到了飞行驾照. 为了庆祝这件事,他决定给自己买一架飞机然后环 ...

  5. BestCoder Round #50 (div.1) 1001 Distribution money (HDU OJ 5364)

    题目:Click here 题意:bestcoder上面有中文题目 #include <iostream> #include <cstdio> #include <cst ...

  6. BestCoder Round 69 Div 2 1001&& 1002 || HDU 5610 && 5611

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5610 如果杠铃总质量是奇数直接impossible 接着就考验耐心和仔细周全的考虑了.在WA了三次后终于发 ...

  7. BestCoder Round #81 (div.2)1001

    Machine Accepts: 580 Submissions: 1890 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65 ...

  8. ACM学习历程—HDU5585 Numbers(数论 || 大数)(BestCoder Round #64 (div.2) 1001)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5585 题目大意就是求大数是否能被2,3,5整除. 我直接上了Java大数,不过可以对末尾来判断2和5, ...

  9. BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)

    Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

随机推荐

  1. Jmeter参数Parameters和Body Data区别

    1.如图: 2.有文章说,Parameters是get的参数:Body Data是post的参数:get的参数存在于url中,post的参数存在于body中:   但是我使用jmeter3.3版本测试 ...

  2. Vs2012在Linux开发中的应用(5):项目属性的定义

    VS的项目属性表实际上是由一系列的XML文件定义的,都存放在C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\2052文件夹下.我们全然能够 ...

  3. web.xml文件中各个配置的说明

    <?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://w ...

  4. Android第一个个人APP(帐号助手)

    第一个app上线了,关于帐号保存的一个app.本地保存,无须联网. 下载地址为:http://android.myapp.com/myapp/detail.htm?apkName=com.weeky. ...

  5. Linux下通过find命令进行rm文件删除的小技巧

       我们常常会通过find命令进行批量操作.如:批量删除旧文件.批量改动.基于时间的文件统计.基于文件大小的文件统计等.在这些操作其中,因为rm删除操作会导致文件夹结构变化,假设要通过find结合r ...

  6. Redis管理各类型存储数据命令

    >>>字符串 1 SET key value 设置指定 key 的值 2 GET key 获取指定 key 的值. 3 GETRANGE key start end 返回 key 中 ...

  7. Python爬虫开发【第1篇】【Scrapy shell】

    Scrapy Shell Scrapy终端是一个交互终端,我们可以在未启动spider的情况下尝试及调试代码,也可以用来测试XPath或CSS表达式,查看他们的工作方式,方便我们爬取的网页中提取的数据 ...

  8. Attribute(特性)

    一向都觉得.NET的Attribute好神秘.一个方框框住的东西,置身于类.方法的头部,本身不在类或方法里面,但又会起作用,有时作用还很大,仿佛充满了魔力.简直给人一种无冕之王,幕后之黑手的感觉! 某 ...

  9. 查看android-support-v4.jar引出的问题

    1.前面博文里也写过如何关联android-support-v4.jar的源码 今天新项目用上述方法的时候,竟然不成功..来回反复试了很长时间,最后发现 新建项目,会自动引用一个类库(自动新建的..) ...

  10. POJ 1269 Intersecting Lines(线段相交,水题)

    id=1269" rel="nofollow">Intersecting Lines 大意:给你两条直线的坐标,推断两条直线是否共线.平行.相交.若相交.求出交点. ...