构造 BestCoder Round #52 (div.2) 1001 Victor and Machine
题意:有中文版的
分析:首先要知道机器关闭后,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的更多相关文章
- TSP+Floyd BestCoder Round #52 (div.2) 1002 Victor and Machine
题目传送门 题意:有中文版的 分析:(出题人的解题报告)我们首先需要预处理出任意两个国家之间的最短距离,因为数据范围很小,所以直接用Floyd就行了.之后,我们用f[S][i]表示访问国家的情况为S, ...
- 判素数+找规律 BestCoder Round #51 (div.2) 1001 Zball in Tina Town
题目传送门 /* 题意: 求(n-1)! mod n 数论:没啥意思,打个表能发现规律,但坑点是4时要特判! */ /***************************************** ...
- BestCoder Round #52 (div.1)
这周六BC和CF又差点打架,精力不够啊...结果打BC没起来,就看了一眼题跑了...今天早上补补吧,(因为今天晚上还要打UER= =) 先放官方题解: 1000 Victor and Machine ...
- BestCoder Round #52 (div.2) HDU 5418 Victor and World (DP+状态压缩)
[题目链接]:pid=5418">click here~~ [题目大意]: 问题描写叙述 经过多年的努力,Victor最终考到了飞行驾照. 为了庆祝这件事,他决定给自己买一架飞机然后环 ...
- BestCoder Round #50 (div.1) 1001 Distribution money (HDU OJ 5364)
题目:Click here 题意:bestcoder上面有中文题目 #include <iostream> #include <cstdio> #include <cst ...
- BestCoder Round 69 Div 2 1001&& 1002 || HDU 5610 && 5611
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5610 如果杠铃总质量是奇数直接impossible 接着就考验耐心和仔细周全的考虑了.在WA了三次后终于发 ...
- BestCoder Round #81 (div.2)1001
Machine Accepts: 580 Submissions: 1890 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65 ...
- ACM学习历程—HDU5585 Numbers(数论 || 大数)(BestCoder Round #64 (div.2) 1001)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5585 题目大意就是求大数是否能被2,3,5整除. 我直接上了Java大数,不过可以对末尾来判断2和5, ...
- 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 ( ...
随机推荐
- Leetcode:search_insert_position
一. 题目 给定一个数组和要插入数的大小.求插入的位置. 二. 分析 太水,直接扫描.过--. class Solution { public: int searchInsert(in ...
- 一个关于MYSQL IFNULL的用法
select a.receiveID,(a.num - IFNULL(b.num,0)) as num from (SELECT num,receiveID from dog_giftnumrecor ...
- SGU - 186 - The Chain (贪心)
186. The Chain time limit per test: 0.25 sec. memory limit per test: 4096 KB input: standard input o ...
- 为经典版eclipse添加web and JavaEE插件
地址:http://download.eclipse.org/releases/juno. 选择Web,XML,Java EE and OSGI Enterprise Development,之后ne ...
- Yii2 mongodb 扩展的where的条件增加大于 小于号
1. mongodb的where中有比較丰富的 条件.例如以下: static $builders = [ 'NOT' => 'buildNotCondition', 'AND' => ' ...
- KindEditor使用过程中,用JQ提交表单时,获取不到编辑器的内容
首先要说明的是.在使用提交button直接提交时.编辑器的内容是能够正常获取的,而使用 jq或js ,如$("#form").submit(),提交时,则编辑器的内容是无法获取的. ...
- sysinfo 系统调用
在分析luci时,看到 usr/lib/luci/sys.lua 里调用 nixio.sysinfo().这是一个c调用lua的用例.在nixio的代码process.c里导出了给lua调用的接口.在 ...
- 追踪分布式Memcached默认的一致性hash算法
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255) ...
- 并不对劲的bzoj5341:loj2553:uoj400:p4565:[Ctsc2018]暴力写挂
题目大意 有两棵\(n\)(\(n\leq366666\))个节点的树,\(T\)和\(T'\),有边权 \(dep(i)\)表示在\(T\)中\(i\)号点到\(1\)号点的距离,\(dep'(i) ...
- 协程的优点(Python)
协程的优点: 协程是进程和线程的升级版,进程和线程都面临着内核态和用户态的切换问题而耗费许多切换时间, 而协程就是用户自己控制切换的时机,不再需要陷入系统的内核态.协程的执行效率非常高.因为子程序切换 ...