Test instructions
Given the three sides of the triangle, are all integers within 10^7, and ask whether the coordinates of the three corners of the triangle can all be integers, outputting any one of them.
Exercises
The first thought is to enumerate the horizontal axis of an edge, and then use the Pythagorean theorem and the angle of calculation to find the coordinates of other points, and then determine whether the conditions are met.
Pro-Test Tle
Until we know the method of constructing the source hook array ...
Each source tick array (a,b,c) satisfies the a*a+b*b=c*c, where a is an odd number and B is an even number.
Enumerate S,t (1<=t<s, and they are odd numbers without common factor)
A=st b= (s*s-t*t)/2 c= (s*s+t*t)/2
Because the maximum number of c= (S*S+T*T)/2 is enumerated up to sqrt (2*c).
Suppose that the three points of a triangle are p,q and R, respectively,
We first fix a point for P (0,0), the other point q is the distance to it is X, and there is a point R with its distance is Y. So the distance between Q and R must be Z.
We enumerate the tick array, if the tick array (A1,B1,C1) of the C1, which is the largest number, equals x, then x coordinates (A1,B1) "Of course it can be (A1,-B1), (-A1,B1), (-A1,-B1), all need to enumerate, the same as"
Then enumeration c equals y of the Tick array, (A2,B2,C2), then the R point coordinates (A2,B2) "Can pre-preprocess these coordinates, into the vector"
Next, determine whether the two coordinate is a Z-apart.
Note that the "a" of the tick array in this way is odd, that is, their multiples (i*a,i*b,i*c), I is a positive integer, and will not be sought out, we are asking for i*c==x, so as long as the X mod c=0 we can multiply the tick array by x/c, adding the alternative options.
Note (0,x) (0,-x) (x,0) (-x,0) and (0,y) (0,-y) (y,0) (-y,0) do not appear in the enumeration source tick array, so you need to manually judge it yourself.
#include <bits/stdc++.h>#defineEPS 1e-9#definefor (i,j,k) for (int i=j;i<=k;i++)#defineMAXN 1005#defineMAXM 40005#defineINF 0X3FFFFFFF#definePB push_back#defineMP Make_pair#defineX First#defineY Second#defineLC (K<<1)#defineRC ((k<<1) 1)using namespaceStd;typedefLong LongLL; LL I,j,k,n,m,x,y,t,ans,big,cas,num,len;BOOLFlag; LL Z; LL Mx,sum,a,b,c;vector<pair<LL,LL> >Xx,yy; ll GCD (ll X, ll y) {returnY? GCD (y, x%y): x;}intMain () {scanf ("%i64d%i64d%i64d",&x,&y,&z); if(x>y) Swap (x, y); if(y>z) swap (y,z); if(x>y) Swap (x, y); MX= (LL) (sqrt (2*Z) +EPS); for(i=1; i<=mx;i+=2)//enumeration source tick array { for(j=i+2; j<=mx;j+=2) { if(GCD (I,J) >1)Continue; A=i*J; b= (j*j-i*i)/2; C= (j*j+i*i)/2; if(x%c==0) {xx. PB (MP (a*x/c,b*x/c)); Xx. PB (MP (a*x/c,-b*x/c)); Xx. PB (MP (-a*x/c,b*x/c)); Xx. PB (MP (-a*x/c,-b*x/c)); Xx. PB (MP (b*x/c,a*x/c)); Xx. PB (MP (b*x/c,-a*x/c)); Xx. PB (MP (-b*x/c,a*x/c)); Xx. PB (MP (-b*x/c,-a*x/c)); } if(y%c==0) {yy. PB (MP (a*y/c,b*y/c)); Yy. PB (MP (a*y/c,-b*y/c)); Yy. PB (MP (-a*y/c,b*y/c)); Yy. PB (MP (-a*y/c,-b*y/c)); Yy. PB (MP (b*y/c,a*y/c)); Yy. PB (MP (b*y/c,-a*y/c)); Yy. PB (MP (-b*y/c,a*y/c)); Yy. PB (MP (-b*y/c,-a*y/c)); }}} xx. PB (MP (0, x)); xx. PB (MP (x,0)); xx. PB (MP (0,-X)); xx. PB (MP (-X,0)); Yy. PB (MP (0, y)); yy. PB (MP (Y,0)); yy. PB (MP (0,-y)); yy. PB (MP (-y,0)); for(i=0; I<xx.size (); i++) { for(j=0; J<yy.size (); j + +) { if((xx[i). X-YY[J]. X) * (Xx[i]. X-YY[J]. X) + (Xx[i]. Y-YY[J]. Y) * (Xx[i]. Y-YY[J]. Y) ==z*z) {printf ("0 0\n%i64d%i64d\n%i64d%i64d\n", Xx[i]. X,xx[i]. Y,YY[J]. X,YY[J]. Y); return 0; }}} printf ("-1\n"); return 0;}
URAL 2032-conspiracy Theory and rebranding "source Hook array"