博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj2398计算几何叉积
阅读量:4987 次
发布时间:2019-06-12

本文共 3015 字,大约阅读时间需要 10 分钟。

Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave Reza a rectangular box to put his toys in. Unfortunately, Reza is rebellious and obeys his parents by simply throwing his toys into the box. All the toys get mixed up, and it is impossible for Reza to find his favorite toys anymore.

Reza's parents came up with the following idea. They put cardboard partitions into the box. Even if Reza keeps throwing his toys into the box, at least toys that get thrown into different partitions stay separate. The box looks like this from the top:

We want for each positive integer t, such that there exists a partition with t toys, determine how many partitions have t, toys.Input

The input consists of a number of cases. The first line consists of six integers n, m, x1, y1, x2, y2. The number of cardboards to form the partitions is n (0 < n <= 1000) and the number of toys is given in m (0 < m <= 1000). The coordinates of the upper-left corner and the lower-right corner of the box are (x1, y1) and (x2, y2), respectively. The following n lines each consists of two integers Ui Li, indicating that the ends of the ith cardboard is at the coordinates (Ui, y1) and (Li, y2). You may assume that the cardboards do not intersect with each other. The next m lines each consists of two integers Xi Yi specifying where the ith toy has landed in the box. You may assume that no toy will land on a cardboard.
A line consisting of a single 0 terminates the input.

Output

For each box, first provide a header stating "Box" on a line of its own. After that, there will be one line of output per count (t > 0) of toys in a partition. The value t will be followed by a colon and a space, followed the number of partitions containing t toys. Output will be sorted in ascending order of t for each box.

Sample Input

4 10 0 10 100 020 2080 8060 6040 405 1015 1095 1025 1065 1075 1035 1045 1055 1085 105 6 0 10 60 04 315 303 16 810 102 12 81 55 540 107 90

Sample Output

Box2: 5Box1: 42: 1 和poj2318几乎一模一样,就是要排个序,二分就行了,判断二分状态用叉积
#include#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define pi acos(-1)#define ll long long#define mod 1000000007using namespace std;const int N=1005,maxn=100005,inf=0x3f3f3f3f;struct point{ int x,y;};struct line{ point a,b;}l[N];int num[N],n,m,res[N];bool comp(const line &u,const line &v){ if(u.a.x!=v.a.x)return u.a.x
0)return 1; return 0;}void Bsearch(int u,int v){ int l=0,r=n+1; for(int i=0;i<50;i++) { int mid=(l+r)/2; if(ok(mid,u,v))l=mid; else r=mid; } num[l]++;}int main(){ while(cin>>n,n){ memset(num,0,sizeof(num)); cin>>m>>l[0].a.x>>l[0].a.y>>l[n+1].b.x>>l[n+1].b.y; for(int i=1;i<=n;i++) { cin>>l[i].a.x>>l[i].b.x; l[i].a.y=l[0].a.y; l[i].b.y=l[n+1].b.y; } sort(l,l+n+1,comp); for(int i=0;i
>u>>v; Bsearch(u,v); } cout<<"Box"<

 

转载于:https://www.cnblogs.com/acjiumeng/p/6681716.html

你可能感兴趣的文章
蓝桥网试题 java 入门训练 A+B问题
查看>>
字典操作学习小结
查看>>
逻辑运算符
查看>>
jstl和jsp脚本变量相互访问
查看>>
重新打理博客
查看>>
Apache+modjk布置tomcat集群
查看>>
Javascript笔记部分
查看>>
【转】微软教学:三种方法屏蔽Win7/Win8.1升级Win10推送
查看>>
1 C# 将对象序列化
查看>>
Qt事件处理(一)
查看>>
HDU 1563 【Find your present!】
查看>>
关于html的meta标签总结
查看>>
1、Spark 通过api,hfile两种形式获取hbase数据,简单样例
查看>>
Openjudge NOI题库 数论185 反正切函数的应用
查看>>
php常用判断的函数
查看>>
第八章 虚拟机字节码执行引擎(待续)
查看>>
HDU 5024
查看>>
MVVMLight消息通知实现机制详解(一)
查看>>
C#验证类 可验证:邮箱,电话,手机,数字,英文,日期,身份证,邮编,网址,IP (转)
查看>>
go——标准命令
查看>>