CF1375I.Cubic Lattice
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A cubic lattice L in 3-dimensional euclidean space is a set of points defined in the following way:
L={u⋅r1+v⋅r2+w⋅r3}u,v,w∈Z
Where r1,r2,r3∈Z3 are some integer vectors such that:
- r1 , r2 and r3 are pairwise orthogonal:
r1⋅r2=r1⋅r3=r2⋅r3=0
Where a⋅b is a dot product of vectors a and b .
- r1 , r2 and r3 all have the same length:
∣r1∣=∣r2∣=∣r3∣=r
You're given a set A={a1,a2,…,an} of integer points, i-th point has coordinates ai=(xi;yi;zi) . Let gi=gcd(xi,yi,zi) . It is guaranteed that gcd(g1,g2,…,gn)=1 .
You have to find a cubic lattice L such that A⊂L and r is the maximum possible.
输入格式
First line contains single integer n ( 1≤n≤104 ) — the number of points in A .
The i -th of the following n lines contains integers xi , yi , zi ( 0<xi2+yi2+zi2≤1016 ) — coordinates of the i -th point.
It is guaranteed that gcd(g1,g2,…,gn)=1 where gi=gcd(xi,yi,zi) .
输出格式
In first line output a single integer r2 , the square of maximum possible r .
In following 3 lines output coordinates of vectors r1 , r2 and r3 respectively.
If there are multiple possible answers, output any.
输入输出样例
输入#1
2 1 2 3 1 2 1
输出#1
1 1 0 0 0 1 0 0 0 1
输入#2
1 1 2 2
输出#2
9 2 -2 1 1 2 2 -2 -1 2
输入#3
1 2 5 5
输出#3
9 -1 2 2 2 -1 2 2 2 -1