编程介的小学生 2017-02-25 12:26 采纳率: 20.5%
浏览 797
已采纳

Bigger Square Please...

Tomy has many paper-squares. The side length(we call it 'size') of them range from 1 to N-1, and he has a really COUNTLESS squares of each kind. He used to be very proud of his squares, but one day, he suddenly wants to have a bigger one -- a square of size N! Though he doesn't have such a square, he can make it up with the squares he has. For example. A square of size 7 can be made up with 9 smaller squares, shown below.

Note that there should be NO empty space in the square, and NO extra paper outside the square, and the small squares should NOT overlap. As you may guess, Tomy wants to make it using the minimal number of squares he has, can you help?

Input

The first line of the input contains a single integer T, indicating the number of test cases. (1<=T<=20) Each case contains a single integer N. (2<=N<=50)

Output

For each test case in the input, print a line containing a single integer K, indicating the minimal number of squares needed to build the target square. In the following K lines, each contains three integers x,y,l indicating the coordinates of top-left corner, and the side length of the corresponding square. (1<=x,y<=N)

Sample Input

3
4
3
7

Sample Output

4
1 1 2
1 3 2
3 1 2
3 3 2
6
1 1 2
1 3 1
2 3 1
3 1 1
3 2 1
3 3 1
9
1 1 2
1 3 2
3 1 1
4 1 1
3 2 2
5 1 3
4 4 4
1 5 3
3 4 1

  • 写回答

2条回答

  • threenewbee 2017-03-03 15:45
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题