Problem ATime limit:3000/1000ms (java/other) Memory limit:65535/32768k (Java/other) total submission (s): 745 Accep Ted Submission (s): 89font:times New Roman | Verdana | Georgiafont Size:←→problem Description Given two triangles, determine if two triangles are similar.
Note that the coordinates of 6 points are strictly 22 not coincident, and certainly can form a triangle.
Note that because the test data has multiple groups, the main function can be in the following format.
#include <stdio.h>
......
int main ()
{
while (scanf ()! = EOF)
{
......
}
return 0;
}input multiple sets of test data inputs (around 200 groups).
Enter the coordinates of the 6 points, the first three points represent the coordinates of the x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6, and the last three points represent the coordinates of the second triangle.
(1<=xi<=100,1<=yi<=100,xi,yi is int type) Output Nosample Input If two triangles are similar output yes
0 11 11 04 33 33 4
Sample Output
Yes
Authormoonlike we figure out six of them, and then sort, min/another minimum = ratio = triangle circumference/Another triangle perimeter (precision I'm taking 1e-6)
#include <stdio.h>//#include <bits/stdc++.h> #include <string.h> #include <iostream> #include <math.h> #include <sstream> #include <set> #include <queue> #include <map> #include < vector> #include <algorithm> #include <limits.h> #define INF 0x3fffffff#define inf 0x3f3f3f3f#define Lson L,m,rt<<1#define Rson m+1,r,rt<<1|1#define LL long long#define ULL unsigned long longusing namespace Std;doub Le x1,y1,x2,y2,x3,y3;double x4,y4,x5,y5,x6,y6;double dis (double x_1,double y_1,double x_2,double y_2) {return sqrt (x_1 -x_2) * (x_1-x_2) + (y_1-y_2) * (y_1-y_2));} int main () {double d[3]; Double e[3]; Double r1,r2; while (cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5 >>X6>>Y6) {D[0]=dis (x1,y1,x2,y2); D[1]=dis (X1,Y1,X3,Y3); D[2]=dis (X2,Y2,X3,Y3); E[0]=dis (X4,Y4,X5,Y5); E[1]=dis (X4,Y4,X6,Y6); E[2]=dis (X5,Y5,X6,Y6); Sort (d,d+3); Sort (e,e+3); cout<<d[0]<<endl; cout<<e[0]<<endl; printf ("%f\n", d[0]/e[0]); r1= (double) d[0]/e[0]*1.0; R2= (Double) (d[0]+d[1]+d[2])/(e[0]+e[1]+e[2]) *1.0; if (ABS (R1-R2) <=1e-6) {puts ("Yes"); } else {puts ("No"); }} return 0;}
East China Jiaotong University 2015 ACM "double Base" Program Design contest 1001