Bottles Arrangement - HUD 4572 不明觉厉
来源:互联网 发布:手机自动更新软件 编辑:程序博客网 时间:2024/04/28 07:08
Bottles Arrangement
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 377 Accepted Submission(s): 291
Problem Description
Hunan cuisine is really wonderful! But if you don’t like spicy food, you will feel terrible since it can be hard for you to find any food without hot pepper here. Big Fan is a student from the north who was not fit to the spicy food in Changsha. He became thinner and thinner because eating little food and maintained his life mostly by drinking water. One day, he found that the wine in Hunan is pretty good, such as Jiugui, Liuyang River, Shaoyang Daqu and so on. He got addicted to it and became an alcoholic, leading a depressed life.
Now N days have passed and he is sobered. He is surprised to find that there are exactly N×M bottles around him. Another amazing fact is that there are N bottles with height 1 and N bottles with height 2 … N bottles with height M.
Now he is interested in playing with these bottles. He wants to arrange all these bottles in a rectangle with M rows and N columns which satisfied:
(1)In any column, there are no bottles with same height;
(2)In any row, the height difference between any two adjacent bottles is no more than 1.
He defined a strange function Y which equals the maximum value of the total height of any single row. He is addicted in arranging these rubbish bottles to find the minimal Y. You know that he cannot solve it with his pour IQ. You are his friend and can’t endure his decadence any more. So you decide to help him solve this problem and then bring him back to study.
Now N days have passed and he is sobered. He is surprised to find that there are exactly N×M bottles around him. Another amazing fact is that there are N bottles with height 1 and N bottles with height 2 … N bottles with height M.
Now he is interested in playing with these bottles. He wants to arrange all these bottles in a rectangle with M rows and N columns which satisfied:
(1)In any column, there are no bottles with same height;
(2)In any row, the height difference between any two adjacent bottles is no more than 1.
He defined a strange function Y which equals the maximum value of the total height of any single row. He is addicted in arranging these rubbish bottles to find the minimal Y. You know that he cannot solve it with his pour IQ. You are his friend and can’t endure his decadence any more. So you decide to help him solve this problem and then bring him back to study.
Input
There are several test cases. For each case, the input contains one line with two integers M and N (1< M <= 10000, 3 <= N < 2×M, It is guaranteed that N is always odd).
The input will finish with the end of file.
The input will finish with the end of file.
Output
For each test case, print the minimal Y in single line.
Sample Input
3 33 5
Sample Output
811HintFor the first case the solution is:1 2 32 1 13 3 2
题意:给你瓶子,让你摆,使得每一列没有高度一样的瓶子,并且每一行的相邻两个瓶子高度差不大于1。问你最小的最大行的高度和是多少。
思路:其实我也不知道为什么,大家不明觉厉一下就行了。
AC代码如下:
#include<cstdio>#include<cstring>using namespace std;int main(){ int i,j,k,n,m,sum; while(~scanf("%d%d",&n,&m)) { sum=0; for(i=0;i<=m/2;i++) sum+=n-i; sum=sum*2-(n-i+1); printf("%d\n",sum); }}
0 0
- Bottles Arrangement - HUD 4572 不明觉厉
- hdoj 4572 Bottles Arrangement
- hdu 4572 Bottles Arrangement
- HDU 4572 Bottles Arrangement
- HDU 4572 Bottles Arrangement
- HDOJ 4572 Bottles Arrangement
- HDU 4572 Bottles Arrangement (思维)
- Hdu 4572 Bottles Arrangement 2013长沙邀请赛
- HDU 4572 Bottles Arrangement 解题报告
- hdu 4572 Bottles Arrangement(构造)
- HDU 4572Bottles Arrangement 找规律
- HDU-4572 Bottles Arrangement (数学)
- HDU 4572 Bottles Arrangement (找规律)
- HDU 4572 Bottles Arrangement找规律 简单题
- hdu 4572 Bottles Arrangement找规律简单题
- 2013 长沙邀请赛 HDU 4572 Bottles Arrangement(推理)
- hdu4572 Bottles Arrangement(找规律)
- HDU4572-Bottles Arrangement-找规律
- json通用转换工具
- cocos2d-x 3.0 rapidJson 解析操作应该注意的细节
- 《Algorithms 4th Edition》读书笔记——2.4 优先队列(priority queue)-Ⅲ
- Android 菜单(OptionMenu)大全 建立你自己的菜单
- leetcode——Reverse Linked List II 选择链表中部分节点逆序(AC)
- Bottles Arrangement - HUD 4572 不明觉厉
- 从操作系统和数据库系统发展理解抽象化思想
- VMware下的RHEL 6.4 安装gcc和gcc-c++
- C# 模拟按键
- 编程基础知识——Java JNI开发流程(1)
- 豆瓣客户端的实现03
- VMWARE虚拟机不能上网三种方法分析
- LINUX core文件
- POJ 1523 SPF(割点所割连通分量数)