弱校联萌十一大决战之厉兵秣马B. Building for UN poj3566

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 hw, 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

题目:点击打开链接

纯纯纯的智商题 也没告诉你每个国家需要多少屋子 也没告诉你取解的范围 就问你怎么排?每个题都special judge你累不累?!

据说这个题的思路是酱紫的 既然要求每个国家的房间至少有两个是挨着的 那么我在第一层要求第一列是1-n 第二列全是1 此时第一个国家满足要求了

当然了 你把我下面写的这个长方体旋转也满足要求

第二层第一列全是2 第二列全是2 那么第二个国家解决了 以此类推  我需要n层来排满 由此 此题可解

#include <iostream>
#include <cstdio>
using namespace std;
char ch[55];
int main()
{
    for(int i=0;i<26;i++){
        ch[i]='A'+i;
    }
    for(int i=26;i<52;i++){
        ch[i]='a'+i-26;
    }
    int n;
    while(cin>>n){
        printf("%d %d 2\n",n,n);
        for(int i=0;i<n;i++){
            for(int k=0;k<n;k++){
                printf("%c",ch[k]);
            }
            puts("");
            for(int k=0;k<n;k++){
                printf("%c",ch[i]);
            }
            puts("");
            if(i!=n-1)puts("");
        }
    }
    return 0;
}


你可能感兴趣的:(poj)