zoukankan      html  css  js  c++  java
  • 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
    ",ans-n);
    40     }
    41     return 0;
    42 }
  • 相关阅读:
    日期时间插件
    QQ在线客服
    dede轮播图
    Animation 案例解释
    transition Css3过度详解
    解决文字无法缩小的问题
    DEDE函数
    hdu 3435 图回路分割
    HDU 4183
    hdu 1569 最小割
  • 原文地址:https://www.cnblogs.com/BBBob/p/6657980.html
Copyright © 2011-2022 走看看