Building for UN
2015-10-05 11:41
363 查看
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
题目大意:给你n个国家,要你在一个建筑里为这些国家排列办公室,要求是每个国家至少有两间办公室是相邻,相邻的概念是要么在同一层有相同的墙壁,要么是上下层,下层的天花板是上层的地板
输出:h,w,l,h是建筑的高度,每层有l条,每条有w个办公室。每层之间有一个空行。
其实只需要看看这两组输出就行:
2 2 2
AB
AA
AB
BB
4 4 4
ABCD
AAAA
ABCD
BBBB
ABCD
CCCC
ABCD
DDDD
这是符合题意的样例;代码就很简单了;
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
题目大意:给你n个国家,要你在一个建筑里为这些国家排列办公室,要求是每个国家至少有两间办公室是相邻,相邻的概念是要么在同一层有相同的墙壁,要么是上下层,下层的天花板是上层的地板
输出:h,w,l,h是建筑的高度,每层有l条,每条有w个办公室。每层之间有一个空行。
其实只需要看看这两组输出就行:
2 2 2
AB
AA
AB
BB
4 4 4
ABCD
AAAA
ABCD
BBBB
ABCD
CCCC
ABCD
DDDD
这是符合题意的样例;代码就很简单了;
[code]#include<iostream> #include<cstdio> #include<cstring> using namespace std; int main() { int n; char s[100]; while(~scanf("%d",&n)) { printf("%d %d 2\n",n,n); for(int i=0; i<n; i++) { if(i<=25) s[i]='A'+i; else s[i]='a'+i-26; } for(int j=0; j<n; j++) { for(int i=0; i<n; i++) cout<<s[i]; cout<<endl; for(int i=0; i<n; i++) { if(j<26) printf("%c",('A'+j)); else printf("%c",('a'+j-26)); } cout<<endl; cout<<endl; } } return 0; }
相关文章推荐
- 【PA2008】【BZOJ3500】Cliquers
- UIButton的EdgeInsets属性
- HDU 5496——Beauty of Sequence——————【考虑局部】
- 双端队列(deque)的应用
- HDU 5496 Beauty of Sequence
- SpriteBuilder中音频文件格式的需要注意的地方
- SpriteBuilder中音频文件格式的需要注意的地方
- SpriteBuilder中音频文件格式的需要注意的地方
- uva 1152(4 values whose sum is zero)
- Quick_Power快速幂
- 报错:setValue:forUndefinedKey:]: this class is not key value coding
- hdu5496 Beauty of Sequence
- 【POJ2524】Ubiquitous Religions
- UVALive 6258 Non-boring sequences 分治
- codeforces 245H H. Queries for Number of Palindromes(区间dp)
- Android call requires API level 12 的解决方案
- UI12_UItabBarViewController
- UI_UITableView的HeaderView
- UI12_UIView动画
- UI:数据库练习、滤镜效果