POJ 2318 TOYS

Source: Internet
Author: User

The calculation of the geometry of the part is relatively simple, the focus is that the two points a little trouble (Daniel ignore), every time you write two points you have to use a pen to simulate, and then to determine.

Because the y1,y2 is public, it is only possible to store x coordinates when the segment is stored. Then the judgment is on the right or the left.

#include <cstdio> #include <cstring> #include <algorithm> #include <vector>using namespace std; const int n=5005;struct line{int x1,x2;}   Line[n];int x1,x2,y1,y2,n,m,num[n];int judge (int x,int y,int ID) {int a1=line[id].x1-x,a2=line[id].x2-x;   int b1=y1-y,b2=y2-y; return A1*B2-A2*B1;}    int main () {int x,y,k=0;        while (scanf ("%d", &n), n!=0) {scanf ("%d%d%d%d%d", &m,&x1,&y1,&x2,&y2);        for (int i=1;i<=n;i++) scanf ("%d%d", &line[i].x1,&line[i].x2);        memset (num,0,sizeof (num));            for (int i=1;i<=m;i++) {scanf ("%d%d", &x,&y);                if (judge (x,y,1) <0)///here to pay attention to {num[0]++;            Continue            if (judge (x,y,n) >0)///Here also note that through drawing can be found, here need to discuss separately.                {num[n]++;            Continue } int l=1,r=n;//Here is a two-point while (r-l>1) {int mid= (L +R)/2;                if (judge (X,y,mid) <0) R=mid;            else L=mid;        } num[l]++;        } if (k>0) printf ("\ n");        k++;    for (int i=0;i<=n;i++) printf ("%d:%d\n", I,num[i]); } return 0;}


POJ 2318 TOYS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.