博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
构造 BestCoder Round #52 (div.2) 1001 Victor and Machine
阅读量:7014 次
发布时间:2019-06-28

本文共 1225 字,大约阅读时间需要 4 分钟。

 

题意:有的

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

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

 

代码:

/************************************************* Author        :Running_Time* Created Time  :2015-8-22 18:55:05* File Name     :A.cpp ************************************************/#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;#define lson l, mid, rt << 1#define rson mid + 1, r, rt << 1 | 1typedef 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;}

  

转载于:https://www.cnblogs.com/Running-Time/p/4751258.html

你可能感兴趣的文章
阿铭每日一题 day 7 20180117
查看>>
关于mount
查看>>
关于在windows上的wamp集成环境和xampp上安装mongo扩展
查看>>
Arctic教程(2.1)—— AUTOSAR应用程序设计入门(接口)
查看>>
大趋势和小趋势的辩证关系(一)
查看>>
AC日记——[SDOI2015]星际战争 洛谷 P3324
查看>>
Gcc编译Objective-C命令行 + UltraEdit(用ultraEdit打造自己的Objective-C IDE for Windows补充)...
查看>>
CSS(一)
查看>>
jquery树形菜单插件treeView
查看>>
autofs文件自动挂载系统
查看>>
bzoj千题计划224:bzoj1023: [SHOI2008]cactus仙人掌图
查看>>
java日期处理SimpleDateFormat等
查看>>
replace characters in a string
查看>>
旋转数组---简单
查看>>
第十六周进度表
查看>>
ASP.NET读取网络图片并在页面上显示
查看>>
python代码审查之flake8
查看>>
我们都曾经历过:生活教会我的8堂人生课
查看>>
Ubuntu中安装XAMPP出错的解决方法
查看>>
Bzoj2563 阿狸和桃子的游戏
查看>>