UVA11737_Extreme Primitive Society
这是隐藏的最深的一个水题。其隐藏性能如此之好,是因为题目的描述十分蛋疼,写了好多好多的废话。
让我们这种过不了六级的孩子情何以堪啊。
是这样的,给你若干个矩形,每次在所有的矩形中两两组合形成许多许多新的矩形,同时宽和高也是任意组合的。(但是组合永远只是一个宽和一个高相组合)
对于每做一次操作,你还可以改变操作后矩形的宽和高一个单位(变小或者变大)
问你变出一个正方形的最小步数是多少?
其实很简单,直接判断初始状态是否为正方形以及第一步可不可以变出正方形。
剩下的情况直接返回(sum+1)/2。
自己理解一下就可以了,太简单,我就不说了。
#include <iostream>
#include <cstdio>
#include <cstring>
#define maxn 510
using namespace std; int w[maxn],h[maxn];
int ans,n; int Abs(int x)
{
return x>=?x:-x;
} int count()
{
int tot=~0u>>;
for (int i=; i<=n; i++) if (w[i]==h[i]) return ;
for (int i=; i<=n; i++)
for (int j=; j<=n; j++)
{
tot=min(tot,Abs(w[i]-h[j]));
}
if (tot<) return ;
return (tot+)/;
} int main()
{
int cas=;
while (scanf("%d",&n)!=EOF)
{
for (int i=; i<=n; i++) scanf("%d%d",&w[i],&h[i]);
ans=count();
printf("Case %d : %d\n",++cas,ans);
}
return ;
}
UVA11737_Extreme Primitive Society的更多相关文章
- UVA 11737 Extreme Primitive Society
非常容易的一个题: 只要判断两种基因相差的最小值就行: #include<cstdio> #include<cstring> #include<algorithm> ...
- Kung fu
1. originPeople in Primitive society(原始社会)in order to survive,they have to hunt for food efficiently ...
- OpenGL ES 3.0: 图元重启(Primitive restart)
[TOC] 背景概述 在OpenGL绘制图形时,可能需要绘制多个并不相连的图形.这样的情况下这几个图形没法被当做一个图形来处理.也就需要多次调用 DrawArrays 或 DrawElements. ...
- iOS CoreData primitive accessor
Given an entity with an attribute firstName, Core Data automatically generates firstName, setFirstNa ...
- 代码的坏味道(3)——基本类型偏执(Primitive Obsession)
坏味道--基本类型偏执(Primitive Obsession) 特征 使用基本类型而不是小对象来实现简单任务(例如货币.范围.电话号码字符串等). 使用常量编码信息(例如一个用于引用管理员权限的常量 ...
- JAVA 1.2(原生数据类型 Primitive Data Type)
1. Java的数据类型分为2类 >> 原生数据类型(primitive data type) >> 引用数据类型(reference data type) 3. 常量和变量 ...
- CLR via C# 3rd - 05 - Primitive, Reference, and Value Types
1. Primitive Types Any data types the compiler directly supports are called primitive types. ...
- [UCSD白板题] Primitive Calculator
Problem Introduction You are given a primitive calculator that can perform the following three opera ...
- Java的主要数据类型(Primitive)
有一系列类需特别对待:可将它们想象成"基本"."主要"或者"主"(Primitive)类型,进行程序设计时要频繁用到它们.之所以要特别对待, ...
随机推荐
- stardict词库
http://download.huzheng.org/zh_CN/ sudo tar -jxvf * -C /usr/share/stardict/dic
- c#获取已安装的所有NET版本
/// <summary> /// 获取已安装的所有NET版本 /// </summary> /// <returns></returns> publi ...
- 【MongoDB】NoSQL Manager for MongoDB 教程(基础篇)
前段时间,学习了一下mongodb,在客户端工具方面,个人认为 NoSQL Manager for MongoDB 是体验比较好的一个,功能也较齐全.可惜在找教程的时候,发现很难找到比较详细的教程,也 ...
- Spring Boot:Caused by: org.apache.ibatis.binding.BindingException: Parameter 'deptId' not found.
1. 错误信息描述 在使用Spring Boot + Mybaits从前台向后台提交数据时,控制台报出该错误信息 2. 报错原因 在dao接口中,该方法拥有两个参数,Mybaits无法区分这两个参数 ...
- flume 安装过程记录
1.安装jdk 2.下载安装包 : apache-flume-1.7.0-bin.tar.gz 安装包是在win下载的,需要拖动到ubuntu下的/home/hadoop (拖动不了需要先安装 lr ...
- 关于nginx反向代理504 gateway time-out配置
问题描述: 使用nginx的默认配置用作后端处理服务的反向代理,针对处理时间超过1分钟的请求,返回504 gateway time-out,但后端服务还在执行中. 原因分析: nginx代理默认超时时 ...
- dubbo 微服务框架
dubbo 注解配置: @Service //Service注解暴露服务 @Configuration // javaconfig形式配置公共模块 @DubboComponentScan // 指定d ...
- 【实用】巧用For xml 生成HTML代码
可以利用SQL的For xml直接生成HTML结构,比如我想生成如下结构: <li> <img src="..."/> <input type=&qu ...
- python数据可视化——matplotlib 用户手册入门:使用指南
参考matplotlib官方指南: https://matplotlib.org/tutorials/introductory/usage.html#sphx-glr-tutorials-introd ...
- Tensorflow - Implement for a Convolutional Neural Network on MNIST.
Coding according to TensorFlow 官方文档中文版 中文注释源于:tf.truncated_normal与tf.random_normal TF-卷积函数 tf.nn.con ...