相似三角形
Time Limit: 1000MS
Memory Limit: 65536KB
Problem Description
给出两个三角形的三条边,判断是否相似。
Input
多组数据,给出6正个整数,a1,b1,c1,a2,b2,c2,分别代表两个三角形。(边长小于100且无序)
Output
如果相似输出YES,如果不相似输出NO,如果三边组不成三角形也输出NO。
Example Input
1 2 3 2 4 6 3 4 5 6 8 10 3 4 5 7 8 10
Example Output
NO YESNO
import java.text.DateFormat; import java.text.DecimalFormat; import java.util.Deque; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int a1 = sc.nextInt(); int a2 = sc.nextInt(); int a3 = sc.nextInt(); int b1 = sc.nextInt(); int b2 = sc.nextInt(); int b3 = sc.nextInt(); if (a1 < a2) { int t = a1; a1 = a2; a2 = t; } if (a1 < a3) { int t = a1; a1 = a3; a3 = t; } if (a2 < a3) { int t = a2; a2 = a3; a3 = t; } if (b1 < b2) { int t = b1; b1 = b2; b2 = t; } if (b1 < b3) { int t = b1; b1 = b3; b3 = t; } if (b2 < b3) { int t = b2; b2 = b3; b3 = t; } if (a3 + a2 <= a1 || b3 + b2 <= b1) { System.out.println("NO"); } else { if (a1 > b1) { int x = a1 % b1; int y = a2 % b2; int z = a3 % b3; if (x == y && x == z && y == z) { System.out.println("YES"); } else { System.out.println("NO"); } } else { int x = b1 % a1; int y = b2 % a2; int z = b3 % a3; if (x == y && x == z && y == z) { System.out.println("YES"); } else { System.out.println("NO"); } } } } sc.close(); } }