| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
Super Knight
Description A super knight moves in the infinite n-dimensional space. Each move it can perform is described by a vector ¨C 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 Sample Output Hint Do
not output any number longer than 50 digits. The test cases are
designed that to each one there is a solution not involving any number
exceeding 1020 by magnitude. Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2006 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator