poj 3566 Building for UN(为联合国而建)
来源:互联网 发布:js style属性 编辑:程序博客网 时间:2024/05/18 00:03
[题目链接] (http://poj.org/problem?id=3566)
题目描述:
Building for UN
Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 1784 Accepted: 802 Special Judge
Description
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 floors, one on top of another. Each floor 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 floor and share a common wall, or if one’s floor 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
The input file consists of a single integer number n (1 ≤ n ≤ 50) — the number of countries that are hosted in the building.
Output
On the first line of the output file write three integer numbers h, w, and l — height, width and length of the building respectively.
h descriptions of floors should follow. Each floor description consists of l lines with w characters on each line. Separate descriptions of adjacent floors 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.
Sample Input
4
Sample Output
2 2 2
AB
CC
zz
zz
Source
Northeastern Europe 2007
言简意赅:
此题主要考察对题目的抽象处理,把算法抽象出来也不过是要满足两个条件的输出:条件1:每个国家的总部办公室都要连接(在隔壁或者上下层)在一起;条件2:每两个国家之间要彼此连接在一起;
纵观,则可以把其抽象为如图所示的样子:
以n==4为例
代码实现如下:
#include <iostream>#include <cstdio>#include <cstring>using namespace std;int main(){ int n; while(scanf("%d",&n)!=EOF) { printf("%d %d 2\n",n,n); if(n<=25) { for(int k=0; k<n; k++) { for(int i=0; i<n; i++) { printf("%c",'A'+i); } printf("\n"); for(int i=0; i<n; i++) { printf("%c",'A'+k); } printf("\n"); printf("\n"); } } else { int i,k; for(k=0; k<n; k++) { for(i=0; i<26; i++) { printf("%c",'A'+i); } for(int p=0; p<n-26; p++) { printf("%c",'a'+p); } printf("\n"); if(k<26) for(i=0;i<n;i++) { printf("%c",'A'+k); } if(k>=26) for(int p=0;p<n;p++) { printf("%c",'a'+k-26); } printf("\n"); printf("\n"); } } } return 0;}
- poj 3566 Building for UN(为联合国而建)
- poj 3566 building for UN
- 联合国大楼UVA1605(Building for UN)
- UVA 1605 Building for UN--联合国大厦
- Building for UN - POJ 3566 想法题
- UVa1605 例题8-2 联合国大楼(Building for UN,ACM/ICPC NEERC 2007)
- 例题8-2 联合国大楼(Building for UN, ACM/ICPC NEERC 2007, UVa1605)
- POJ 3566 Building for UN (无脑构造 水题)
- POJ 3566 (弱校联萌十一大决战之厉兵秣马 B. Building for UN)
- B - Building for UN
- 1605 - Building for UN
- 1605 - Building for UN
- UVA1605-Building for UN
- Building for UN
- UVA_1605: Building for UN
- 1605 - Building for UN
- Building for UN
- UVa1605 Building for UN
- jQuery UI基础----8jQuery UI Widgets-AutoComplete(自动补全
- python+Eclipse+pydev环境搭建
- 近期目标
- jQuery UI基础----9jQurey UI Widgets-Datepicker(日期选择器
- Socket编程基础之服务端与客户端简单通信
- poj 3566 Building for UN(为联合国而建)
- 啃系列---Scikit Learn
- [NOIP2014]珠心算测验 T1
- jQuery UI基础----10jQuery UI Widgets-Dialog(对话框
- Activity加载模式
- MySql对用户的管理【初级】
- C++设计模式——抽象工厂模式
- jQuery UI基础----11jQuery UI Widgets-progressbar(进度条
- please select a valid interpreter