Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Dot_and_poligon {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- double arrx[] = new double[n + 1];
- double arry[] = new double[n + 1];
- for (int i = 0; i < n; i++) {
- arrx[i] = sc.nextDouble();
- arry[i] = sc.nextDouble();
- }
- double x = sc.nextDouble();
- double y = sc.nextDouble();
- arrx[n] = arrx[0];
- arry[n] = arry[0];
- int ch = -1;
- for (int i = 0; i < n + 1; i++) {
- double d = arrx[i] * arry[i + 1] - arrx[i + 1] * arry[i] + arrx[i + 1] * y - x * arry[i + 1] + x * arry[i]
- - arrx[i] * y;
- if (ch == -1) {
- if (d > 0)
- ch = 1;
- if (d < 0)
- ch = 0;
- } else {
- if (d < 0 && ch == 1) {
- ch = 2;
- }
- if (d > 0 && ch == 0) {
- ch = 2;
- }
- }
- }
- if (ch != 2)
- System.out.println("YES");
- else
- System.out.println("NO");
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement