构造 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 ( ...
随机推荐
- apc smart UPS下使用apcupsd注意事项
公司的apc smart UPS安装有管理卡(似乎是AP-9631),server环境有FreeBSD.Windows Server.Linux(CentOS.Ubuntu) 实际使用中有例如以下问题 ...
- 从头认识Spring-3.1 简单的AOP日志实现-某方法之前的前后记录日志
这一章节我们引入简单的AOP日志实现. 1.domain 蛋糕类: package com.raylee.my_new_spring.my_new_spring.ch03.topic_1_1; pub ...
- Android ImageLoader 本地缓存
Android ImageLoader 本地缓存 本地缓存 ...
- list if else 遍历 特征合并
特征合并 import re l = ['a', 'b1'] ll = [i if re.search('\d', i) is None else i[0:re.search('\d', i).end ...
- Java 解析excel2003和2007区别和兼容性问题(POI操作)
最近在使用POI对excel操作中发现一些问题,2003和2007的区别还是蛮大的: 2007相关的包: poi-3.9.jar poi-examples-3.8.jar poi-excelant-3 ...
- YTU 2844: 改错题A-看电影
2844: 改错题A-看电影 时间限制: 1 Sec 内存限制: 128 MB 提交: 69 解决: 47 题目描述 注:本题只需要提交标记为修改部分之间的代码,请按照C++方式提交. 小平家长为 ...
- UITableview控件简单介绍
注意点:数据源方法只能在控制器里设置 一.基本介绍 在众多移动应⽤用中,能看到各式各样的表格数据 . 在iOS中,要实现表格数据展示,最常用的做法就是使用UITableView,UITableView ...
- 【繁琐工作自动化】pandas 处理 excel 文件
0. 一般处理 读取 excel 格式文件:df = pd.read_excel('xx.xlsx'),下面是一些简单查看文件内容的函数: df.head():展示前五行: df.columns:展示 ...
- linux 忘记root(这里以centos 6.5为例)密码的解决办法
在使用linux的过程中有时候会忘记root用户的密码(尤其是进行交接而文档内容不全的时候),这个时候我们就可以进入单用户模式来重置root用户密码.下面来讲解重置root密码的方式,也可以说是破解r ...
- java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId
运行spring报了这个错误,网上说是spring版本冲突,检查maven依赖,发现我依赖的是spring-core.3.0.5,但是spring-orm和spring-tx依赖了spring-bea ...