UVA1605-Building for UN(思维)

Posted npugen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVA1605-Building for UN(思维)相关的知识,希望对你有一定的参考价值。

Problem UVA1605-Building for UN

Accept: 398  Submit: 2303
Time Limit: 10000 mSec

技术分享图片 Problem 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 ?oors, one on top of another. Each ?oor is a rectangular grid of the same dimensions, each cell of this grid is an o?ce. Two o?ces 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 o?ces 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 o?ces, 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 o?ces of di?erent countries. There should be at most 1 000 000 o?ces in the building. Each o?ce should be occupied by a country. There should be exactly n di?erent countries in the building. In this problem the required building design always exists. Print a blank line between test cases.

 

技术分享图片 Sample Input

4
 

技术分享图片 Sample Output

2 2 2

AB

CC


zz zz

 

题解:水题,啥限制都没有,不要求最小,字典序之类的,随便画一画就出来了。

 

 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 const int maxn = 60;
 6 
 7 char gra[maxn][maxn], gra2[maxn][maxn];
 8 
 9 int main()
10 {
11     int n;
12     while (~scanf("%d", &n)) {
13         printf("%d %d %d
", 2, n, n);
14         for (int i = 0; i < n; i++) {
15             for (int j = 0; j < n; j++) {
16                 if(i < 26) gra[i][j] = A + i;
17                 else gra[i][j] = a + i - 26;
18             }
19         }
20 
21         for (int j = 0; j < n; j++) {
22             for (int i = 0; i < n; i++) {
23                 if(j < 26) gra2[i][j] = A + j;
24                 else gra2[i][j] = a + j - 26;
25             }
26         }
27 
28         for (int i = 0; i < n; i++) {
29             for (int j = 0; j < n; j++) {
30                 printf("%c", gra[i][j]);
31             }
32             printf("
");
33         }
34         printf("
");
35         for (int i = 0; i < n; i++) {
36             for (int j = 0; j < n; j++) {
37                 printf("%c", gra2[i][j]);
38             }
39             printf("
");
40         }
41         printf("
");
42     }
43     return 0;
44 }

 



以上是关于UVA1605-Building for UN(思维)的主要内容,如果未能解决你的问题,请参考以下文章

UVa 1605 - Building for UN

例题 8-2 UVA-1605Building for UN

UVA - 1605 Building for UN (联合国大楼)

Uva破损的键盘

每日一题 UVA - 340 阅读理解+模拟

UVa1635Irrelevant Elements - 唯一分解定理