接替关键:和上题类似,输出不同,注意输入这道题需要排序。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long ll;
struct point{
int x,y;
};
int n,m,x1,x2,y11,y2;
struct Line{
point a,b;
}A[];
double operator*(point p1,point p2){return p1.x*p2.y-p2.x*p1.y;}
point operator-(point A,point B){return {A.x-B.x,A.y-B.y};}
int pos[];
bool judge(point t,int mid){//叉积
point tt=A[mid].b-A[mid].a;
int ans=tt*(t-A[mid].a);
return ans<;
}
bool cmp(Line a,Line b){
return a.a.x<b.a.x;
} int erfen(point xx){
int l=,r=n;
while(l<r){
int mid=(l+r)>>;
if(judge(xx,mid)) r=mid;
else l=mid+;
}
return r;
} int num[];
int main(){
while(scanf("%d",&n)!=EOF&&n){
scanf("%d%d%d%d%d",&m,&x1,&y11,&x2,&y2);
for(int i=;i<n;i++){
int xd,xu;
scanf("%d%d",&xu,&xd);
A[i]={{xu,y11},{xd,y2}};
}
sort(A,A+n,cmp);
memset(pos,,sizeof pos);
for(int i=;i<m;i++){
int xx,yy;
scanf("%d%d",&xx,&yy);
point t={xx,yy};
int ans=erfen(t);
pos[ans]++;
}
memset(num,,sizeof num);
for(int i=;i<=;i++){
if(pos[i]) num[pos[i]]++;
}
printf("Box\n");
for(int i=;i<=;i++){
if(!num[i]) continue;
printf("%d: %d\n",i,num[i]);
}
}
return ;
}

[poj2398]Toy Storage的更多相关文章

  1. poj2398 Toy Storage 计算几何,叉积,二分

    poj2398 Toy Storage 链接 poj 题目大意 这道题的大概意思是先输入6个数字:n,m,x1,y1,x2,y2.n代表卡片的数量,卡片竖直(或倾斜)放置在盒内,可把盒子分为n+1块区 ...

  2. [POJ2398]Toy Storage(计算几何,二分,判断点在线段的哪一侧)

    题目链接:http://poj.org/problem?id=2398 思路RT,和POJ2318一样,就是需要排序,输出也不一样.手工画一下就明白了.注意叉乘的时候a×b是判断a在b的顺时针还是逆时 ...

  3. POJ 2398 - Toy Storage 点与直线位置关系

    Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5439   Accepted: 3234 Descr ...

  4. POJ 2398 Toy Storage(计算几何,叉积判断点和线段的关系)

    Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3146   Accepted: 1798 Descr ...

  5. POJ 2318 TOYS && POJ 2398 Toy Storage(几何)

    2318 TOYS 2398 Toy Storage 题意 : 给你n块板的坐标,m个玩具的具体坐标,2318中板是有序的,而2398无序需要自己排序,2318要求输出的是每个区间内的玩具数,而231 ...

  6. Toy Storage

    Toy Storage 题型与2318 TOYS一样,注意要对线段排序,现在模板又更新了~~ #include<iostream> #include<cstdio> #incl ...

  7. 2018.07.04 POJ 2398 Toy Storage(二分+简单计算几何)

    Toy Storage Time Limit: 1000MS Memory Limit: 65536K Description Mom and dad have a problem: their ch ...

  8. POJ 2398 Toy Storage (叉积判断点和线段的关系)

    题目链接 Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4104   Accepted: 2433 ...

  9. poj 2398 Toy Storage(计算几何)

    题目传送门:poj 2398 Toy Storage 题目大意:一个长方形的箱子,里面有一些隔板,每一个隔板都可以纵切这个箱子.隔板将这个箱子分成了一些隔间.向其中扔一些玩具,每个玩具有一个坐标,求有 ...

随机推荐

  1. Memcache 笔记(2)

    一.Memcache概述出现的原因:随着数据量的增大,访问的集中,使得数据库服务器的负担加重,数据库响应恶化,网站显示延迟等 memcache:是高性能的分布式内存缓存服务器.通过缓存数据库的查询结果 ...

  2. 有些事情不要强求 PS:日常收集语录

    有些事情不要强求 1.有些事,我们明知道是错的,也要去坚持,因为不甘心:有些人,我们明知道是爱的,也要去放弃,因为没结局:有时候,我们明知道没路了,却还在前行,因为习惯了. 2.以为蒙上了眼睛,就可以 ...

  3. java.net.SocketException: No buffer space available 异常

    http://stackoverflow.com/questions/10088363/java-net-socketexception-no-buffer-space-available-maxim ...

  4. 1 Python 环境搭建

    Python可应用于多平台包括 Linux 和 Mac OS X. 你可以通过终端窗口输入 "python" 命令来查看本地是否已经安装Python以及Python的安装版本. U ...

  5. 配合Jenkins自动化构建,bat脚本(一)

    C:\Windows\System32\inetsrv\appcmd.exe stop site ServiceIIS C:\Windows\System32\inetsrv\appcmd.exe s ...

  6. hdu4771 Stealing Harry Potter's Precious(DFS,BFS)

    练习dfs和bfs的好题. #include<iostream> #include<cstdio> #include<cstdlib> #include<cs ...

  7. CodeForces - 687D: Dividing Kingdom II (二分图&带权并查集)

    Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great ...

  8. 2.Linux下安装Jenkins

    1.安装jenkins的前提是安装好jdk环境,自行安装jdk,若安装成功后,使用一下命令即可成功安装jenkins: wget -O /etc/yum.repos.d/jenkins.repo ht ...

  9. Python 函数之迭代器和生成器

    1.迭代器 迭代器是访问集合元素的一种方式.迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束.迭代器只能往前不会后退,迭代器仅仅在迭代到某个元素时才计算该元素,而在这之前或之后,元素可 ...

  10. WPF中DataGrid控件的过滤(Filter)性能分析及优化

    DataGrid控件是一个列表控件, 可以进行过滤,排序等.本文主要针对DataGrid的过滤功能进行分析, 并提供优化方案. 1)DataGrid的过滤过程:      用户输入过滤条件       ...