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

#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. css Flex布局(一)

    网页布局(layout) 布局的传统解决方案,基于盒状模型,依赖 display属性 + position属性 + float属性.它对于那些特殊布局非常不方便,比如,垂直居中就不容易实现. 6个属性 ...

  2. Boost 读写锁

    //#########测试多线程,读写锁,递归锁 #include <boost/thread.hpp> #include <boost/thread/recursive_mutex ...

  3. 前端调错看ajax请求操作

    ---------------------------------------------------------------------------------------------------- ...

  4. LeetCode Output Contest Matches

    原题链接在这里:https://leetcode.com/problems/output-contest-matches/description/ 题目: During the NBA playoff ...

  5. redis 双写一致性问题

    首先,缓存由于其高并发和高性能的特性,已经在项目中被广泛使用.在读取缓存方面,大家没啥疑问,都是按照下图的流程来进行业务操作. 但是在更新缓存方面,对于更新完数据库,是更新缓存呢,还是删除缓存.又或者 ...

  6. 神秘常量!用0x077CB531计算末尾0的个数,32位数首位相连

    大家或许还记得 Quake III 里面的一段有如天书般的代码,其中用到的神秘常量 0x5F3759DF 究竟是怎么一回事,着实让不少人伤透了脑筋.今天,我见到了一段同样诡异的代码.     下面这个 ...

  7. webrtc 术语

    参考网址 https://webrtcglossary.com/ ORTC stands for Object-RTC.ORTC is an initiative involving Google, ...

  8. 无法确定要使用哪一版本的 ASP.NET Web Pages。

    若要使用此站点,请在站点的 web.config 文件中指定一个版本.有关详细信息,请参阅 Microsoft 支持站点上的以下文章: http://go.microsoft.com/fwlink/? ...

  9. java代码equals方法

    package com.bc; public class Test_6 { // 我们知道java中的每个类都继承自Object类,equals是Object方法之一 String name; int ...

  10. QQ控件时光轴特效总结

    1.插入HTML数据 插入html代码,一般的做法是通过document.getElementById("").innerHTML来实现. 然而在该控件中,它通过JS replac ...