• poj2398Toy Storage


    http://poj.org/problem?id=2398

    跟2318一样 数据还少些 直接枚举的 2318还用了二分 叉积判左右

     1 #include <iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<iostream>
     5 #include<stdlib.h>
     6 #include<algorithm>
     7 #include<cmath>
     8 using namespace std;
     9 struct pointt
    10 {
    11     double x1,x2,mi,ma;
    12 }p[1010];
    13 int num[1010],co[1010];
    14 bool cmp(pointt a,pointt b)
    15 {
    16     if(a.ma==b.ma)
    17     return a.mi<b.mi;
    18     return a.ma<b.ma;
    19 }
    20 int cross(pointt a,pointt b)
    21 {
    22     if((a.x1*b.x2-a.x2*b.x1)>0)
    23     return 1;
    24     return 0;
    25 }
    26 int main()
    27 {
    28     int i,j,k,n,m;
    29     double x1,y1,x2,y2,x,y;
    30     while(cin>>n)
    31     {
    32         if(n==0)
    33         break;
    34         memset(num,0,sizeof(num));
    35         memset(co,0,sizeof(co));
    36         cin>>m;
    37         cin>>x1>>y1>>x2>>y2;
    38         for(i = 1; i <= n ; i++)
    39         {
    40             cin>>p[i].x1>>p[i].x2;
    41             p[i].ma = max(p[i].x1,p[i].x2);
    42             p[i].mi = max(p[i].x1,p[i].x2);
    43         }
    44         p[n+1].x1 = x2;
    45         p[n+1].x2 = x2;
    46         p[n+1].ma = p[n+1].mi = x2;
    47         sort(p,p+n+2,cmp);
    48         for(i = 1; i <= m ; i++)
    49         {
    50             cin>>x>>y;
    51             for(j = 1 ; j <= n+1 ; j++)
    52             {
    53                 pointt a,b;
    54                 a.x1 = p[j].x1-p[j].x2;
    55                 a.x2 = y1-y2;
    56                 b.x1 = x-p[j].x2;
    57                 b.x2 = y-y2;
    58                 if(cross(a,b))
    59                 {
    60                     num[j]++;
    61                     break;
    62                 }
    63             }
    64         }
    65         cout<<"Box\n";
    66         for(j = 1 ; j <= n+1 ;j++)
    67             if(num[j])
    68                 co[num[j]]++;
    69         for(j = 1 ; j <= n+1 ;j++)
    70         {
    71             if(co[j])
    72             cout<<j<<": "<<co[j]<<endl;
    73         }
    74     }
    75     return 0;
    76 }
    View Code
  • 相关阅读:
    XP下关于快速切换用户功能的相关编程
    CRC原理及其逆向分析方法
    爱的十个秘密4.给予的力量
    爱的十个秘密1.序幕
    隐式链接无.LIB动态链接库
    电影图标黑客帝国(The Matrix)
    手机图标
    圣斗士图标:十二星座黄金圣衣
    MAC风格图标
    GB码与BIG5
  • 原文地址:https://www.cnblogs.com/shangyu/p/3104578.html
Copyright © 2020-2023  润新知