HDU4572 Bottles Arrangement
/*
HDU4572 Bottles Arrangement
http://acm.hdu.edu.cn/showproblem.php?pid=4572
数论 找规律
题意:有m行n列和1-n的数各n个,将其填在m×n的格子里
要求同一列中的数各不相同,同一行中相邻两数的差的绝对值不超过1。
求每一行中值的和的最小值。 这道题很神奇,比赛的时候yy了一发交了上去,没想到真的A了
赛后看题解,发现大家各种yy,然而没有人和我的yy一样,
也许我脑洞过于新奇吧23333
首先这个值肯定比n*m要小,于是感觉应该是n*m-a的形式,有yy出
a与n有关
于是乎发现3对应1,5对应4,然后一眼看出这是(n/2)^2
真是敢写敢过
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <map>
#include <set>
//#define test
using namespace std;
const int Nmax=;
int main()
{
#ifdef test
#endif
int n,m;
while(scanf("%d%d",&m,&n)==)
{
int ans=n*m;
n/=;
n*=n;
printf("%d\n",ans-n);
}
return ;
}
HDU4572 Bottles Arrangement的更多相关文章
- HDU 4572 Bottles Arrangement(找规律,仔细读题)
题目 //找规律,123321123321123321…发现这样排列恰好可以错开 // 其中注意题中数据范围: M是行,N是列,3 <= N < 2×M //则猜测:m,m,m-1,m-1 ...
- 2013 ACM-ICPC长沙赛区全国邀请赛——Bottles Arrangement
这题当时竟然没看啊…… 找规律:求和m+m+m-1+m-1+……前n项 ;}
- HDU 4572 Bottles Arrangement
具体的证明:点击打开链接 我的想法: 要想保证题目所说 构造最小行的和,仅仅能是这样的情况 ..... m-3 m-2 m-1 m | m m-1 m-2 m-3 ...
- CF 672C Recycling Bottles[最优次优 贪心]
C. Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- codeforces A. Sereja and Bottles 解题报告
题目链接:http://codeforces.com/problemset/problem/315/A 题目意思:有n个soda bottles,随后给出这n个soda bottles的信息.已知第 ...
- Codeforces Round #352 (Div. 2) C. Recycling Bottles 贪心
C. Recycling Bottles It was recycling day in Kekoland. To celebrate it Adil and Bera went to Centr ...
- [leetcode-526-Beautiful Arrangement]
Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is const ...
- zoj3777 Problem Arrangement
The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward i ...
- ZOJ 3777-Problem Arrangement(状压DP)
B - Problem Arrangement Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %l ...
随机推荐
- axis2的wsdl无法使用eclipse axis1插件来生成client--解决方法
使用jetty+axis2实现webservice服务端,且无需使用axis2命令生成服务端代码.仅仅要services.xml配置实现类. project为gradleproject配置文件在src ...
- oc28--Property增强
// // Person.h #import <Foundation/Foundation.h> @interface Person : NSObject /* { @public int ...
- 倒排索引PForDelta压缩算法——基本假设和霍夫曼压缩同
PForDelta算法 PForDelta算法最早由Heman在2005年提出,它允许同时对整个chunk数据(例128个数)进行压缩处理.基础思想是对于一个chunk的数列(例128个),认为其中占 ...
- hdoj--1027--Ignatius and the Princess II(dfs)
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- python Paramiko 模块远程管理主机
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import paramiko import os, stat import sys import ope ...
- 原生JS---1
js的历史 在上个世纪的1995年,当时的网景公司正凭借其Navigator浏览器成为Web时代开启时最著名的第一代互联网公司. 由于网景公司希望能在静态HTML页面上添加一些动态效果,于是叫Bren ...
- SQLServer2008 关于数值字段列的累计
create table #temp20110610( id int identity(1,1), date varchar(8), qty float) insert int ...
- 2018年排名前20的数据科学Python库
Python 在解决数据科学任务和挑战方面继续处于领先地位.业已证明最有帮助的Python库,我们选择 20 多个库,因为其中一些库是相互替代的,可以解决相同的问题.因此,我们将它们放在同一个分组. ...
- Java关于反射的用法
一. 首先是准备一个需要反射的类 public class Person { private String name; private int age; public String sex; publ ...
- Step by Step 开发dynamics CRM
这里是作为开发贴的总结. 现在plugin和workflow系列已经终结. 希望这些教程能给想入坑的小伙伴一些帮忙. CRM中文教材不多, 我会不断努力为大家提供更优质的教程. Plugin 开发系列 ...