相似三角形
Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
给出两个三角形的三条边,判断是否相似。
Input
多组数据,给出6正个整数,a1,b1,c1,a2,b2,c2,分别代表两个三角形。(边长小于100且无序)
Output
如果相似输出YES,如果不相似输出NO,如果三边组不成三角形也输出NO。
Sample Input
1 2 3 2 4 6 3 4 5 6 8 10 3 4 5 7 8 10
Sample Output
NO YES NO
import java.util.*;
class F
{
double a,b,c;
public F(int a, int b, int c)
{
this.a = a * 1.0;
this.b = b * 1.0;
this.c = c * 1.0;
}
public boolean YN()
{
if(a + b > c && a + c > b && b + c > a)
return true;
else return false;
}
public boolean judge(F s)
{
if((a / s.a == b / s.b && b / s.b == c / s.c) ||(a / s.a == b / s.c && b / s.c == c / s.b)|| (a / s.b == b / s.a && b / s.a == c / s.c) || (a / s.b == b / s.c && b / s.c == c / s.a) || (a / s.c == b / s.a && b / s.a == c / s.b) || (a / s.c == b / s.b && b / s.b == c / s.a))
return true;
else return false;
}
}
public class Main {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
while(reader.hasNext())
{
F f = new F(reader.nextInt(), reader .nextInt(), reader.nextInt());
F ff = new F(reader.nextInt(), reader .nextInt(), reader.nextInt());
if(f.YN() && ff.YN())
{
if(f.judge(ff))
{
System.out.println("YES");
}
else System.out.println("NO");
}
else
{
System.out.println("NO");
}
}
reader.close();
}
}