Description
Hunan cuisine is really wonderful! But ifyou don’t like spicy food, you will feel terrible since it can be hard for youto find any food without hot pepper here. Big Fan is a student from the northwho was not fit to the spicy food in Changsha. He became thinner and thinnerbecause 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 issobered. He is surprised to find that there are exactlyN×Mbottles around him. Another amazing fact is that there areN bottleswith height 1 and N bottles with height 2 … N bottles with heightM.
Now he is interested in playing with these bottles. Hewants to arrange all these bottles in a rectangle withM rows andNcolumns which satisfied:
u In any column, there are no bottles withsame height;
u In any row, the height difference betweenany two adjacent bottles is no more than 1.
He defined a strange functionYwhich equals the maximum value of the total height of any single row. He isaddicted in arranging these rubbish bottles to find the minimalY. Youknow that he cannot solve it with his pour IQ. You are his friend and can’tendure his decadence any more. So you decide to help him solve this problem andthen bring him back to study.
Input
There are several test cases. For eachcase, the input contains one line with two integersM andN(1< M <= 10000, 3 <= N < 2×M, It is guaranteedthatN is always odd).
The input will finish with the end of file.
Output
For each test case, print the minimalYin single line.
Sample Input
3 3
3 5
Sample Output
8
11
Hint
For the first case the solution is:
1 2 3
2 1 1
3 3 2
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
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;
}