构造 BestCoder Round #52 (div.2) 1001 Victor and Machine
2024-08-30 17:53:09
题意:有中文版的
分析:首先要知道机器关闭后,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;
}
最新文章
- PHP日志压缩下载
- STM3210x建工程库函数版本
- 环回接口(loopback interface)的新认识
- CSS - Tooltip-arrow 绘制三角形
- RxJava简介
- python核心编程学习记录之Python对象
- windows8.1安装
- Vim 配置 winmanager
- Android开发之意图解析
- squid透明代理+iptables防火墙,多网卡详细配置
- Javascript 中创建自定义对象的方法(设计模式)
- Java注解处理器--编译时处理的注解
- sql 查询 以结果集为对象左连接
- vue图片被加了盗链
- How to gitignore
- 分布式事务XA
- python中isdigit
- HTML第二篇
- oracle 切换用户操作--or--sys用户密码忘记
- springboot 表单校验