CF1375I.Cubic Lattice

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A cubic lattice LL in 33-dimensional euclidean space is a set of points defined in the following way:

L={ur1+vr2+wr3}u,v,wZL=\{u \cdot \vec r_1 + v \cdot \vec r_2 + w \cdot \vec r_3\}_{u, v, w \in \mathbb Z}

Where r1,r2,r3Z3\vec r_1, \vec r_2,\vec r_3 \in \mathbb{Z}^3 are some integer vectors such that:

  • r1\vec r_1 , r2\vec r_2 and r3\vec r_3 are pairwise orthogonal:

r1r2=r1r3=r2r3=0\vec r_1 \cdot \vec r_2 = \vec r_1 \cdot \vec r_3 = \vec r_2 \cdot \vec r_3 = 0

Where ab\vec a \cdot \vec b is a dot product of vectors a\vec a and b\vec b .

  • r1\vec r_1 , r2\vec r_2 and r3\vec r_3 all have the same length:

r1=r2=r3=r|\vec r_1| = |\vec r_2| = |\vec r_3| = r

You're given a set A={a1,a2,,an}A=\{\vec a_1, \vec a_2, \dots, \vec a_n\} of integer points, ii-th point has coordinates ai=(xi;yi;zi)a_i=(x_i;y_i;z_i) . Let gi=gcd(xi,yi,zi)g_i=\gcd(x_i,y_i,z_i) . It is guaranteed that gcd(g1,g2,,gn)=1\gcd(g_1,g_2,\dots,g_n)=1 .

You have to find a cubic lattice LL such that ALA \subset L and rr is the maximum possible.

输入格式

First line contains single integer nn ( 1n1041 \leq n \leq 10^4 ) — the number of points in AA .

The ii -th of the following nn lines contains integers xix_i , yiy_i , ziz_i ( 0<xi2+yi2+zi210160 < x_i^2 + y_i^2 + z_i^2 \leq 10^{16} ) — coordinates of the ii -th point.

It is guaranteed that gcd(g1,g2,,gn)=1\gcd(g_1,g_2,\dots,g_n)=1 where gi=gcd(xi,yi,zi)g_i=\gcd(x_i,y_i,z_i) .

输出格式

In first line output a single integer r2r^2 , the square of maximum possible rr .

In following 33 lines output coordinates of vectors r1\vec r_1 , r2\vec r_2 and r3\vec r_3 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
首页