uva 1605 building for UN ——yhx
The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have a
form of a rectangular parallelepiped and will consist of several rectangular 
oors, one on top of another.
Each 
oor is a rectangular grid of the same dimensions, each cell of this grid is an office.
Two offices are considered adjacent if they are located on the same 
oor and share a common wall,
or if one's 
oor is the other's ceiling.
The St. Petersburg building will host n national missions. Each country gets several offices that
form a connected set.
Moreover, modern political situation shows that countries might want to form secret coalitions. For
that to be possible, each pair of countries must have at least one pair of adjacent offices, so that they
can raise the wall or the ceiling they share to perform secret pair-wise negotiations just in case they
need to.
You are hired to design an appropriate building for the UN.
Input
Input consists of several datasets. Each of them has a single integer number n (1  n  50) | the
number of countries that are hosted in the building.
Output
On the rst line of the output for each dataset write three integer numbers h, w, and l | height, width
and length of the building respectively.
h descriptions of 
oors should follow. Each 
oor description consists of l lines with w characters on
each line. Separate descriptions of adjacent 
oors with an empty line.
Use capital and small Latin letters to denote offices of different countries. There should be at most
1 000 000 offices in the building. Each office should be occupied by a country. There should be exactly
n different countries in the building. In this problem the required building design always exists.
Print a blank line between test cases.
#include<cstdio>
#include<cstring>
char turn(int x)
{
if (x<=) return x+'a'-;
return x-+'A';
}
int main()
{
int i,j,k,m,n,p,q,x,y,z,l,h;
char c;
bool b=;
while (scanf("%d",&n)==)
{
if (b==) b=;
else printf("\n");
printf("2 %d %d\n",n,n);
for (i=;i<=n;i++)
{
for (j=;j<=n;j++)
printf("%c",turn(i));
printf("\n");
}
printf("\n");
for (i=;i<=n;i++)
{
for (j=;j<=n;j++)
printf("%c",turn(j));
printf("\n");
}
}
}
和http://www.cnblogs.com/AwesomeOrion/p/5380752.html这道题一样,只是让你找到一组解。那我只要存心构造万能解即可。
我的方法是:建两层,每一层n*n,第一层横着按顺序排列1..n,第二层竖着按顺序排列1..n,这样每两个国家都会交叉。
uva 1605 building for UN ——yhx的更多相关文章
- UVA 1605 Building for UN
		
题意: 有n个国家,要求你设计一栋楼并为这n个国家划分房间,要求国家的房间必须连通,且每两个国家之间必须有一间房间是相邻的 分析: 其实非常简单,完全被样例误导了.只需要设计两层就可以了,每个国家占第 ...
 - UVA 1605 Building for UN(思维)
		
题目链接: https://cn.vjudge.net/problem/UVA-1605#author=0 /* 问题 设计一个包含若干层的联合国大厦,其中每一层都是等大的网格,每个格子分配给一个国家 ...
 - Uva 1605  Building for UN【构造法】
		
题意:给出n个国家,给它们分配办公室,使得任意两个国家都有一对相邻的格子 看的紫书,最开始看的时候不理解 后来还是搜了题解--- 发现是这样的 比如说5个国家 应该输出 AAAA BBBB CCCC ...
 - UVA - 1605 Building for UN (联合国大楼)
		
题意:一个联合国大楼每层都有数量相等大小相同的格子,将其分配给n个国家,使任意两个不同的国家都相邻(同层有公共边或相邻层的同一个格子). 分析:可以设计一个只有两层的大楼,第一层每个国家占一行,第二层 ...
 - 贪心水题。UVA 11636 Hello World,LA 3602 DNA Consensus String,UVA 10970 Big Chocolate,UVA 10340 All in All,UVA 11039 Building Designing
		
UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r ...
 - UVa 1605 (构造) Building for UN
		
题意: 有n个国家,要设计一栋长方体的大楼,使得每个单位方格都属于其中一个国家,而且每个国家都要和其他国家相邻. 分析: 紫书上有一种很巧妙的构造方法: 一共有2层,每层n×n.一层是每行一个国家,另 ...
 - UVa 11039 - Building designing 贪心,水题 难度: 0
		
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
 - UVA 11039 Building designing 贪心
		
题目链接:UVA - 11039 题意描述:建筑师设计房子有两条要求:第一,每一层楼的大小一定比此层楼以上的房子尺寸要大:第二,用蓝色和红色为建筑染色,每相邻的两层楼不能染同一种颜色.现在给出楼层数量 ...
 - UVA 11039 - Building designing(DP)
		
题目链接 本质上是DP,但是俩变量就搞定了. #include <cstdio> #include <cstring> #include <algorithm> u ...
 
随机推荐
- ActiveReports 报表应用教程 (6)---分组报表
			
在 ActiveReports 中可以设置单级分组.嵌套分组,同时,还可以使用表格.列表以及矩阵等数据区域控件对数据源进行分组操作.分组报表在商业报表系统中应用不胜枚举,客户信息归类统计表.商品分类统 ...
 - php学习笔记:文件的上传(包含设置文件的上传大小限制)
			
今天写的是文件上传,前几天自学的正规则又忘记了,用了很笨的方法去判断格式,直接上代码: <?php /** * Created by PhpStorm. * User: Administrato ...
 - HTML   运算符、类型转换
			
1.类型转换: 分为自动转换和强制转换,一般用强制转换. 其他类型转换为整数:parseInt(): 其他类型转换为小数:parseFloat(): 判断是否是一个合法的数字类型:isNaN(): 是 ...
 - django性能优化
			
1. 内存.内存,还是加内存 2. 使用单独的静态文件服务器 3. 关闭KeepAlive(如果服务器不提供静态文件服务,如:大文件下载) 4. 使用memcached 5. 使用select_rel ...
 - express新旧语法对比
			
备个份, 原文: http://stackoverflow.com/questions/25550819/error-most-middleware-like-bodyparser-is-no-lon ...
 - 六个字符,带你领略JavaScript   (js的艺术编写)
			
正文从这开始- JavaScript是一门神奇且奇妙的编程语言,我们有时候用它来写一些看似疯狂的代码,但这些代码依然可被执行且运行结果十分有趣.JavaScript 试图帮助我们将一些数据类型转化为我 ...
 - js得到屏幕宽高、页面宽高 (window.screen.availHeight)等--笔记
			
window.screen.availWidth 返回当前屏幕宽度(空白空间) window.screen.availHeight 返回当前屏幕高度(空白空间) window.screen.width ...
 - 【原】训练自己haar-like特征分类器并识别物体(1)
			
本系列文章旨在学习如何在opencv中基于haar-like特征训练自己的分类器,并且用该分类器用于模式识别.该过程大致可以分为一下几个大步骤: 1.准备训练样本图片,包括正例及反例样本 2.生成样本 ...
 - JSPatch一些容易犯错的地方
			
JSPatch一些自己使用后的发现: 1.JS不区分整数和浮点数.解析字典以后的value不需要通过 floatValue等方法转换,而是自动就转换成对应的数据类型. 2.nil在JSPatch中 不 ...
 - 斯坦福iOS7公开课10笔记及演示Demo
			
这一节主要介绍了多线程中的串行队列以及滚动视图UIScrollView. 1 .多线程 这一节只是简单介绍了多线程的串行队列,即把任务加入线程队列后按顺序逐步执行. (1)目前iOS多线程提供的方法主 ...