View Code of Problem 32

import java.util.Scanner;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int x = sc.nextInt();
			int y = sc.nextInt();
			int e[][] = new int[5][3];
			for (int i = 0; i < e.length; i++) {
				for (int j = 0; j < e[i].length; j++) {
					e[i][j] = sc.nextInt();
				}
			}
			for (int i = 0; i < 5; i++) {
				for (int j = 0; j < 5; j++) {
					if ((e[j][0] - x) * (e[i][1] - y) == (e[i][0] - x) * (e[j][1] - y)) {
						if (e[j][0] < e[i][0] || e[j][1] < e[i][1]) {
							e[i][0] = x;
							e[i][1] = y;
						}
					}
				}
			}

			int panduan = 0;
			int d = sc.nextInt();
			double r = sc.nextDouble();
			for (int i = 0; i < 5; i++) {
				double c = Math.sqrt((e[i][0] - x) * (e[i][0] - x) + (e[i][1] - y) * (e[i][1] - y));
				if (c <= d) {
					if (r * c >= e[i][2]) {
						panduan = 1;
					}
				}
			}
			if (panduan == 1) {
				System.out.println("yes");
			} else {
				System.out.println("NO");
			}
			
		}
	}
}

Double click to view unformatted code.


Back to problem 32