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

题目大意是把一个矩形分成h层w行l列,然后往里面放元素,同一种元素一定要全部相邻,不同种元素要两两相接触。

这里的相邻只要同一层相邻或者不同层上下相邻都行。

一种构造的方法是:

构造两层,

让每一个元素占据第一层某一行,第二层的某一列。

这种方法是满足条件的,不要被样例的方法迷惑了。

代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#define LL long long using namespace std; int n, item[]; void init()
{
for (int i = ; i < ; ++i)
item[i] = 'a'+i;
for (int i = ; i < ; ++i)
item[i] = 'A'+i-;
} void output()
{
printf("2 %d %d\n", n, n);
for (int i = ; i < n; ++i)
{
for (int j = ; j < n; ++j)
printf("%c", item[j]);
printf("\n");
}
printf("\n");
for (int i = ; i < n; ++i)
{
for (int j = ; j < n; ++j)
printf("%c", item[i]);
printf("\n");
}
} int main()
{
//freopen("test.in", "r", stdin);
init();
while (scanf("%d", &n) != EOF)
output();
return ;
}

最新文章

  1. 整型信号量和PV操作(计算机操作系统)
  2. 转 - ubuntu apache2下目录结构
  3. Spring 4.0.2 学习笔记(1) - 最基本的注入
  4. 【JAVA与XML、dtd约束、Schema约束】
  5. httpClient 4.x post get方法
  6. linux mysql开启远程链接
  7. php mkdir函数
  8. 网络编程(一) 利用NSURLSession发送GET POST请求
  9. 深入理解JavaScript的闭包特性 如何给循环中的对象添加事件(转载)
  10. 【RegExp】JavaScript中正则表达式判断匹配规则以及常用方法
  11. 【Android】ScaleAnimation 详解
  12. CentOS安装和配置Rsync进行文件同步
  13. springboot项目新功能开发
  14. SVN Attempted to lock an already-locked dir异常解决方法
  15. 通过端口号查找进程号并杀掉进程window和Linux版本
  16. OC与AS3的观察者模式比较以及外部回调
  17. php_soap扩展应用
  18. javascript promise编程
  19. HttpClient 解释
  20. MIME类型是什么?包含哪些类型?

热门文章

  1. Android 快速开发系列 ORMLite 框架最佳实践之实现历史记录搜索
  2. SDOI2012 Round1 day2 集合(set)解题报告
  3. ubuntu 安装wine
  4. 九度OJ 1336:液晶屏裁剪 (GCD)
  5. The path &quot;fos_user.from_email.address&quot; cannot contain an empty value, but got null.
  6. mongodb 的注意点
  7. 文件传输协议FTP
  8. 2个canvas叠加运用(时钟例子)
  9. 2018svn1
  10. python开发环境必备之vim配置