HDU4572(找规律)
来源:互联网 发布:如何修改电脑网络通道 编辑:程序博客网 时间:2024/06/10 18:44
Bottles Arrangement
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 112 Accepted Submission(s): 84
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
正式赛的时候一直以为是数独游戏,一直想通过递归找到答案,但能力太差无从下手,直到想了很久找了规律才做出来的,然后又看了大神的解释,方才醒悟!
Bottles ArrangementTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 112 Accepted Submission(s): 84Problem 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. 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. Output For each test case, print the minimal Y in single line. Sample Input3 33 5 #include <cstdio>int main(){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;}
- HDU4572(找规律)
- hdu4572 Bottles Arrangement(找规律)
- HDU4572-Bottles Arrangement-找规律
- 找规律
- 找规律!
- 找规律
- 找规律,
- 找规律
- 找规律
- 找规律
- 找规律
- 找规律
- 找规律
- 找规律
- 找规律
- 找规律
- 递归(找规律、找出口)
- 数字找规律
- mvc 控制反转Ninject(依赖注入容器)
- find命令详解 linux学习笔记十二之find命令详解
- Start GO
- 入手ST-LINK开发/MDK/KEIL4
- Android依据名字通过反射获取在drawable中的图片
- HDU4572(找规律)
- 利用HTML5画出一个坦克的形状
- wifi详解(二)
- 与机房收费系统图的初步情结
- linux系统如何清除bond信息
- 区分Galaxy GT-I9300中通话记录和短信记录
- wifi详解(三)
- poj 1256 深搜全排列 Anagram
- 浅析BMP位图文件结构(含Demo)