Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2011
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. import static java.lang.Math.max;
  2. import static java.lang.Math.min;
  3.  
  4. import java.io.*;
  5. import java.math.*;
  6. import java.util.*;
  7. import java.awt.geom.*;
  8.  
  9. class Task implements Runnable{
  10.    
  11.     final String fname="";
  12.    
  13.     BufferedReader in;
  14.     PrintWriter out;
  15.     StringTokenizer st;
  16.    
  17.     private String next() throws Exception {
  18.         if (st == null || !st.hasMoreTokens()) {
  19.             String line=in.readLine().trim();
  20.             while(line.length() == 0)
  21.                 line=in.readLine().trim();
  22.             st = new StringTokenizer(line);
  23.         }
  24.         return st.nextToken();
  25.     }
  26.    
  27.     private int nextInt() throws Exception {
  28.         return Integer.parseInt(next());
  29.     }
  30.     private long nextLong() throws Exception {
  31.         return Long.parseLong(next());
  32.     }
  33.     private double nextDouble() throws Exception {
  34.         return Double.parseDouble(next());
  35.     }
  36.    
  37.     public static void main(String[] args) {
  38.         new Thread(null, new Task(), "", (1<<25)).start();
  39.     }
  40.    
  41.     public void run() {
  42.         try {
  43.             in = new BufferedReader(new FileReader("input.txt"));
  44.             out = new PrintWriter(new FileWriter("output.txt"));
  45.             //in = new BufferedReader(new InputStreamReader(System.in));
  46.             //out = new PrintWriter(System.out);
  47.             solve();
  48.         } catch (Exception e) {
  49.             throw new RuntimeException(e);
  50.         } finally {
  51.             out.close();
  52.         }
  53.     }
  54.    
  55.     double py[],px[];
  56.     double dy[],dx[];
  57.    
  58.     public void solve() throws Exception {
  59.         int n=nextInt(); int m=nextInt();
  60.         py=new double [n];
  61.         px=new double [n];
  62.         dy=new double [n];
  63.         dx=new double [n];
  64.        
  65.         for (int i=0;i<n;i++) {
  66.             px[i]=nextDouble();
  67.             py[i]=nextDouble();
  68.         }
  69.        
  70.         for (int i=0;i<n;i++) {
  71.             dx[i]=nextDouble();
  72.             dy[i]=nextDouble();
  73.         }
  74.        
  75.         GeneralPath path = new GeneralPath();
  76.        
  77.         for (int i=0;i<n;i++) {
  78.             path.append(new QuadCurve2D.Double(px[i], py[i], dx[i], dy[i], px[(i+1)%n], py[(i+1)%n]), true);
  79.         }
  80.        
  81.         Area global = new Area(path);
  82.        
  83.         int ret=0;
  84.        
  85.         for (int i=0;i<m;i++) {
  86.             if (global.contains(nextDouble(),nextDouble())) ret++;
  87.         }
  88.        
  89.         out.println(ret);
  90.     }
  91.    
  92.  
  93. }
  94.  
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement