题意:输入一个数字n代表有n个国家,输出一种楼层排布,使得任意两个不同得国家都有一对相邻的格子(同层有公共边 或 相邻层同一位置)。并且自己国家的格子都是间接连通的。
此题答案不唯一,Special Judge。
其实仔细想想2层楼就够了,一层是每一行是一种国家,另一层是每一列是一种国家。
#include <stdio.h>
int main()
{
int n;
char ch[100];
for(int i = 0; i < 26; i++)
{
ch[i] = 'a' + i;
ch[26 + i] = 'A' + i;
}
int f = 0;
while(~scanf("%d", &n))
{
if(f) puts("");
f++;
printf("2 %d %d\n", n, n);
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
printf("%c", ch[i]);
}
puts("");
}
puts("");
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
printf("%c", ch[j]);
}
puts("");
}
}
return 0;
}