Original question:
The Nations has decided to build a new headquarters in Saint Petersburg, Russia. It would have a form of a rectangular parallelepiped and would 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. Offices is considered adjacent if they be located on the same floor and share a common wall, or if one's floor is th E other ' s ceiling.
The St. Petersburg building would host N national missions. Each country gets several offices this form a connected set.
Moreover, modern political situation shows, countries might want to form secret coalitions. For the is possible, each pair of countries must has at least a pair of adjacent offices, so that they can raise th e wall or the ceiling they share to perform secret pair-wise negotiations just in case they need to.
You is hired to design a appropriate building for the UN.
Input
Input consists of several datasets. Each of them have a single integer number n (1≤n≤50)-the number of countries that is hosted in the building.
Output
The first 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 floors should follow. Each floor description consists of L lines with W characters on each line. Separate descriptions of adjacent floors with a empty line. Use capital and small Latin letters to denote offices of different countries. There should is at most 1 offices in the building. Each office should is occupied by a country. There should is exactly n different 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
Chinese:
give you a number n means how many countries, and now you want to design such a building, the office of each country in the building is adjacent to other countries ' offices, each country's office can have more than one. Let you output the scheme.
#include <bits/stdc++.h>
using namespace std;
int floor[51][51];
Char country[51];
int main ()
{
Ios::sync_with_stdio (false);
for (int i=1;i<=50;i++)
{for
(int j=1;j<=50;j++)
{
floor[i][j]=i;
}
}
for (int i=0;i<25;i++)
{
country[i+1]= ' A ' +i;
Country[i+26]= ' a ' +i;
}
int n;
while (Cin>>n)
{
cout<<2<< "" <<n<< "" <<n<<endl;
for (int i=1;i<=n;i++)
{for
(int j=1;j<=n;j++)
cout<<country[floor[i][j]];
cout<<endl;
}
cout<<endl;
for (int i=1;i<=n;i++)
{for
(int j=1;j<=n;j++)
cout<<country[floor[j][i]];
cout<<endl;
}
}
return 0;
}
The following:
The
can be reminiscent of a two-dimensional coordinate system, if each country's office is represented by a straight line, then all countries are drawn with horizontal lines, and if a vertical bar is bound to intersect with all the dashes. So as long as the design of the two floors, the first tier of all countries have their offices listed. On the second floor, the offices of all countries can be placed on line.