HDU4572 Bottles Arrangement

 1 /*
 2  HDU4572 Bottles Arrangement
 3  http://acm.hdu.edu.cn/showproblem.php?pid=4572
 4  数论 找规律
 5  题意:有m行n列和1-n的数各n个,将其填在m×n的格子里
 6  要求同一列中的数各不相同,同一行中相邻两数的差的绝对值不超过1。
 7  求每一行中值的和的最小值。
 8 
 9  这道题很神奇,比赛的时候yy了一发交了上去,没想到真的A了
10  赛后看题解,发现大家各种yy,然而没有人和我的yy一样,
11  也许我脑洞过于新奇吧23333
12  首先这个值肯定比n*m要小,于是感觉应该是n*m-a的形式,有yy出
13  a与n有关
14  于是乎发现3对应1,5对应4,然后一眼看出这是(n/2)^2
15  真是敢写敢过
16  */
17 #include <cstdio>
18 #include <algorithm>
19 #include <cstring>
20 #include <cmath>
21 #include <vector>
22 #include <queue>
23 #include <iostream>
24 #include <map>
25 #include <set>
26 //#define test
27 using namespace std;
28 const int Nmax=1005;
29 int main()
30 {
31     #ifdef test
32     #endif
33     int n,m;
34     while(scanf("%d%d",&m,&n)==2)
35     {
36         int ans=n*m;
37         n/=2;
38         n*=n;
39         printf("%d\n",ans-n);
40     }
41     return 0;
42 }

 

posted @ 2017-04-02 00:11  BBBob  阅读(273)  评论(0编辑  收藏  举报