uva 1605 building for UN ——yhx
来源:互联网 发布:医疗软件项目 编辑:程序博客网 时间:2024/06/04 23:03
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.
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.
1 #include<cstdio> 2 #include<cstring> 3 char turn(int x) 4 { 5 if (x<=26) return x+'a'-1; 6 return x-27+'A'; 7 } 8 int main() 9 {10 int i,j,k,m,n,p,q,x,y,z,l,h;11 char c;12 bool b=0;13 while (scanf("%d",&n)==1)14 {15 if (b==0) b=1;16 else printf("\n");17 printf("2 %d %d\n",n,n);18 for (i=1;i<=n;i++)19 {20 for (j=1;j<=n;j++)21 printf("%c",turn(i));22 printf("\n");23 }24 printf("\n");25 for (i=1;i<=n;i++)26 {27 for (j=1;j<=n;j++)28 printf("%c",turn(j));29 printf("\n");30 }31 }32 }
和http://www.cnblogs.com/AwesomeOrion/p/5380752.html这道题一样,只是让你找到一组解。那我只要存心构造万能解即可。
我的方法是:建两层,每一层n*n,第一层横着按顺序排列1..n,第二层竖着按顺序排列1..n,这样每两个国家都会交叉。
0 0
- uva 1605 building for UN ——yhx
- uva 1605 building for UN ——yhx
- uva 1605 ——Building for UN
- UVa 1605 Building for UN ——思路题
- UVA 1605 - Building for UN
- Uva - 1605 - Building for UN
- UVA 1605 Building for UN
- uva 1605 Building for UN
- UVA 1605 Building for UN
- UVA 1605Building for UN
- uva uva 1605 - Building for UN
- Building for UN UVA
- Building for UN UVA
- Building for UN UVA
- UVA - 1605 Building for UN 水题
- UVA 1605(p236)----Building for UN
- uva 1605 Building for UN 构造?随意
- UVa OJ 1605 - Building for UN
- 从IaaS到PaaS,天云软件助力企业云化有底气!
- 将varchar修改为clob的方法
- uva 120 stacks of flapjacks ——yhx
- 稀疏矩阵
- 二分查找(折半查找) -- 已排序序列的查找算法
- uva 1605 building for UN ——yhx
- uva 1152 4 values whose sum is zero ——yhx
- 用反射和注解,绑定控件的id和点击事件
- Github Android 开源库前100名简介
- PE 427
- linux下设置自动启动服务(程序)
- Remove Element
- 插入排序 优化
- NOIP2008普及组传球游戏(动态规划)——yhx