编程介的小学生 2017-08-15 06:51 采纳率: 0.2%
浏览 816
已采纳

Super Knight

Description

A super knight moves in the infinite n-dimensional space. Each move it can perform is described by a vector – a vector (a1, a2, …, an) indicates that a move from the square (with coordinates) (x1, x2, …, xn) to the square (x1 + a1, x2 + a2, …, xn + an) or (x1 − a1, x2 − a2, …, xn − an) is possible. Each knight has a prescribed set of such vectors, describing the moves this knight can make. For each knight we assume that this knight can reach anywhere in the space if it is allowed (but actually disallowed) to move along a fractional part of a vector.

We say two knights are equivalent, if they can reach exactly the same squares starting from the square (0, 0, …, 0) (by making many moves, perhaps). (Let us point out that equivalent knights may reach these squares in different number of moves). It can be shown that for every knight there exists an equivalent one whose moves are described by only n vectors.

Given a set of m (m > n) vectors describing the moves of a super knight, determine an equivalent knight as mentioned above.

Input

The input contains exactly one test case. The first line of input contains two integers m and n (2 ≤ n < m ≤ 100, n ≤ 10, n · m ≤ 200). The next m lines each contains an integral n-dimensional vector (a1, a2, …, an). It is guaranteed that for all i (1 ≤ i ≤ n) if n = 2, |ai| ≤ 103, otherwise |ai| ≤ 102.

Output

Output n n-dimensional vectors describing the moves of an equivalent knight, each on a separate line.

Sample Input

3 2
1 0
0 5
0 7
Sample Output

1 0
0 1

  • 写回答

1条回答 默认 最新

  • devmiao 2017-08-27 09:14
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 已知手指抓握过程中掌指关节、手指各关节和指尖每一帧的坐标,用贝塞尔曲线可以拟合手指抓握的运动轨迹吗?
  • ¥50 libwebsockets 如何添加其他socket事件回调
  • ¥50 实现画布拖拽算子排布,通过flink实现算子编排计算,请提供思路
  • ¥15 esium自定义材质拉伸问题
  • ¥15 cmake+mingw使用<mysqlx/xdevapi.h>报错
  • ¥15 eNSP中防火墙的使用
  • ¥15 不能对数据库增删改但是可以查询
  • ¥15 关于#mlnet#的问题:mlnet相关请求(语言-c#)
  • ¥15 lvgl7.11怎么做出文字被选中的效果
  • ¥50 如何快速查看手机目标app的主要服务器ip
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部