编程介的小学生 2017-10-12 09:57 采纳率: 20.5%
浏览 1346
已采纳

Magic of David Copperfield

Description

The well-known magician David Copperfield loves to show the following trick: a square with N rows and N columns of different pictures appears on a TV screen. Let us number all the pictures in the following order:
1

2

...

N

:

:

...

:

N*(N-1)+1

N*(N-1)+2

...

N*N

Each member of the audience is asked to put a finger on the upper left picture (i.e., picture number one) and The Magic begins: the magician tells the audience to move the finger k1 times through the pictures (each move is a shift of the finger to the adjacent picture up, down, left or right provided that there is a picture to move to), then with a slight movement of his hand he removes some of the pictures with an exclamation "You are not there!", and ... it is true - your finger is not pointing to any of the pictures removed. Then again, he tells the audience to make k2 moves, and so on. At the end he removes all the pictures but one and smiling triumphantly declares, "I've caught you" (applause).

Just now, David is trying to repeat this trick. Unfortunately, he had a hard day before, and you know how hard to conjure with a headache. You have to write a program that will help David to make his trick.
Input

The input contains a single integer number N (2<=N<=100).
Output

Your program should write the following lines with numbers to the output file:

k1 x1,1 x1,2 ... x1,m1

k2 x2,1 x2,2 ... x2,m2

...

ke xe,1 xe,2 ... xe,me

where ki is a number of moves the audience should make on the i-th turn (2N<=k<=10000). All ki should be different (i.e. ki <> kj when i <> j). xi,1, xi,2, ... , xi, mi are the numbers of the pictures David should remove after the audience will make ki moves (the number of the pictures removed is arbitrary, but each picture should be listed only once, and at least one picture should be removed on each turn).

A description of the every next turn should begin with a new line. All numbers on each line should be separated by one space. After e iterations, all pictures except one should be removed.
Sample Input

3
Sample Output

8 4 6
13 9
10 7 1
7 8
11 3 5

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-30 13:54
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用