Hdu 4572 Bottles Arrangement 2013长沙邀请赛
2013-06-03 21:59
399 查看
Bottles Arrangement
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each test case, print the minimal Y in single line.
[align=left]Sample Input[/align]
3 3
3 5
[align=left]Sample Output[/align]
8
11
Hint
For the first case the solution is:
1 2 3
2 1 1
3 3 2
[align=left]Source[/align]
2013
ACM-ICPC长沙赛区全国邀请赛——题目重现
[align=left]Recommend[/align]
zhoujiaqi2010
.
#include <cstdio> #include <cstring> #include <cstdlib> using namespace std; int main(){ //freopen("DataIn.in", "r",stdin); //freopen("DataOut.out","w",stdout); int n, m; while (scanf("%d%d", &m,&n)!=EOF){ int tot=n*m-((n-1)>>1)*((n-1)>>1); printf("%d\n", tot); } return 0; }
相关文章推荐
- 2013 长沙邀请赛 HDU 4572 Bottles Arrangement(推理)
- HDU 4572 Bottles Arrangement(数学推公式)——2013 ACM-ICPC长沙赛区全国邀请赛
- 2013 长沙邀请赛 HDU 4571 Travel in time(dp)
- HDU 4571 Travel in time ★(2013 ACM/ICPC长沙邀请赛)
- HDU 4568 Hunter(最短路径+DP)(2013 ACM-ICPC长沙赛区全国邀请赛)
- HDU 4571 Travel in time ★(2013 ACM/ICPC长沙邀请赛)
- HDU 4571 Travel in time(最短路径+DP)(2013 ACM-ICPC长沙赛区全国邀请赛)
- HDU - 4571 Travel in time 2013长沙邀请赛
- Hdu 4565 So easy! 2013长沙邀请赛
- hdu 4565 So Easy! /2013 ACM-ICPC 长沙赛区全国邀请赛A题 矩阵乘法
- HDU 4569 Special equations(枚举+数论)(2013 ACM-ICPC长沙赛区全国邀请赛)
- HDU - 4568 Hunter 2013长沙邀请赛
- HDU 4571 Travel in time 2013 ACM-ICPC长沙赛区全国邀请赛G题
- HDU - 4570 Multi-bit Trie 2013长沙邀请赛
- Hdu 4566 Circle Game 2013长沙邀请赛
- HDU - 4567 Brilliant Programmers Show 2013长沙邀请赛
- Hdu 4569 Special equations 2013长沙邀请赛
- HDU 4565 So Easy!(数学+矩阵快速幂)(2013 ACM-ICPC长沙赛区全国邀请赛)
- HDU 4565 So Easy!(思想+矩阵快速幂)——2013 ACM-ICPC长沙赛区全国邀请赛
- Hdu 4568 Hunter 2013长沙邀请赛