poj2398计算几何叉积
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
A line consisting of a single 0 terminates the input.
Output
Sample Input
4 10 0 10 100 0
20 20
80 80
60 60
40 40
5 10
15 10
95 10
25 10
65 10
75 10
35 10
45 10
55 10
85 10
5 6 0 10 60 0
4 3
15 30
3 1
6 8
10 10
2 1
2 8
1 5
5 5
40 10
7 9
0
Sample Output
Box
2: 5
Box
1: 4
2: 1
和poj2318几乎一模一样,就是要排个序,二分就行了,判断二分状态用叉积
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007 using namespace std; const int N=,maxn=,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<v.a.x;
return u.a.y<v.a.y;
}
bool ok(int m,int x,int y)
{
float f=(l[m].b.x-l[m].a.x)*(y-l[m].a.y)-(l[m].b.y-l[m].a.y)*(x-l[m].a.x);
if(f>)return ;
return ;
}
void Bsearch(int u,int v)
{
int l=,r=n+;
for(int i=;i<;i++)
{
int mid=(l+r)/;
if(ok(mid,u,v))l=mid;
else r=mid;
}
num[l]++;
}
int main()
{
while(cin>>n,n){
memset(num,,sizeof(num));
cin>>m>>l[].a.x>>l[].a.y>>l[n+].b.x>>l[n+].b.y;
for(int i=;i<=n;i++)
{
cin>>l[i].a.x>>l[i].b.x;
l[i].a.y=l[].a.y;
l[i].b.y=l[n+].b.y;
}
sort(l,l+n+,comp);
for(int i=;i<m;i++)
{
int u,v;
cin>>u>>v;
Bsearch(u,v);
}
cout<<"Box"<<endl;
memset(res,,sizeof(res));
for(int i=;i<=n;i++)res[num[i]]++;
for(int i=;i<=n;i++)
if(res[i]!=)
cout<<i<<": "<<res[i]<<endl;
}
return ;
}
poj2398计算几何叉积的更多相关文章
- poj1039 Pipe(计算几何叉积求交点)
F - Pipe Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Submit Sta ...
- 【BZOJ1132】【POI2008】Tro 计算几何 叉积求面积
链接: #include <stdio.h> int main() { puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢"); puts("网 ...
- [ An Ac a Day ^_^ ] CodeForces 659D Bicycle Race 计算几何 叉积
问有多少个点在多边形内 求一遍叉积 小于零计数就好了~ #include<stdio.h> #include<iostream> #include<algorithm&g ...
- poj 1654 Area(计算几何--叉积求多边形面积)
一个简单的用叉积求任意多边形面积的题,并不难,但我却错了很多次,double的数据应该是要转化为long long,我转成了int...这里为了节省内存尽量不开数组,直接计算,我MLE了一发...,最 ...
- ACM/ICPC 之 计算几何入门-叉积-to left test(POJ2318-POJ2398)
POJ2318 本题需要运用to left test不断判断点处于哪个分区,并统计分区的点个数(保证点不在边界和界外),用来做叉积入门题很合适 //计算几何-叉积入门题 //Time:157Ms Me ...
- 【自用】OI计划安排表一轮
网络流√ 上下界最大流√ 线性规划转费用流√ RMQ优化建图√ 单纯形√ 字符串相关 hash√ 扩展KMP 回文自己主动机 数据结构 平衡树 启示式合并 替罪羊树 LCT 树套树 KD-Tree 二 ...
- poj2398 Toy Storage 计算几何,叉积,二分
poj2398 Toy Storage 链接 poj 题目大意 这道题的大概意思是先输入6个数字:n,m,x1,y1,x2,y2.n代表卡片的数量,卡片竖直(或倾斜)放置在盒内,可把盒子分为n+1块区 ...
- TOYS - POJ 2318(计算几何,叉积判断)
题目大意:给你一个矩形的左上角和右下角的坐标,然后这个矩形有 N 个隔板分割成 N+1 个区域,下面有 M 组坐标,求出来每个区域包含的坐标数. 分析:做的第一道计算几何题目....使用叉积判断方 ...
- hrbustoj 1318:蛋疼的蚂蚁(计算几何,凸包变种,叉积应用)
蛋疼的蚂蚁 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 39(22 users) Total Accepted: 26 ...
随机推荐
- STM32F103RC进入串口3接收中断产生HardFault_Hander问题解决!
最近在以前的项目上添加串口3通讯后,程序一进入接收中断后就产生HardFault_Hander.串口3发送数据一切正常,当打开串口3接收功能时,程序就处于HardFault_Hander状态,而导致死 ...
- CAS进行https到http的改造方案,结合cookie源码分析
先说具体的改造方案: 服务端: 一.CAS Server端的修改 1.找到cas\WEB-INF\deployerConfigContext.xml 对以下Bean增加参数p:requireSecur ...
- CentOS7搭建Confluence Wiki
前言 在艾佳生活实习时,有三款团队协作系统特别喜欢:Wiki.Jira和Jenkins.对于Jenkins的搭建,之前<自动部署工具Jenkins>有过记录.这次,搭建一个Wiki,作为知 ...
- java对String进行sha1加密
1.使用apache的codec jar包对string进行加密,先下载并引入jar包: http://commons.apache.org/proper/commons-codec/ 2.生成: S ...
- Tcl与Design Compiler (八)——DC的逻辑综合与优化
本文属于原创手打(有参考文献),如果有错,欢迎留言更正:此外,转载请标明出处 http://www.cnblogs.com/IClearner/ ,作者:IC_learner 对进行时序路径.工作环 ...
- 读书笔记 effective c++ Item 39 明智而谨慎的使用private继承
1. private 继承介绍 Item 32表明C++把public继承当作”is-a”关系来对待.考虑一个继承体系,一个类Student public 继承自类Person,如果一个函数的成功调用 ...
- Tomcat源码分析(一)
这段时间简单的看了一下Tomcat的源码,在这里做个笔记! 1. tomcat 架构图 Catalina: tomcat的顶级容器,main()方法中就是通过,创建Catalina 对象实例,来启 ...
- XJOI1657&Codevs1255搭积木【树状动规】
搭积木 一种积木搭建方式,高为H的积木,最底层有M个积木,每一层的积木数是他的低一层的积木数+1或-1.总共有N个积木.(且每行积木数不超过10)比如上图N=13 H=6 M=2. 输入格式: 第一行 ...
- 性能测试培训:tomcat性能调优方法
性能测试培训:tomcat性能调优方法 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.在poptest的loadrunner ...
- 老李推荐:第8章3节《MonkeyRunner源码剖析》MonkeyRunner启动运行过程-启动AndroidDebugBridge 3
首先它通过查找JVM中的System Property来找到"com.android.monkeyrunner.bindir"这个属性的值,记得前面小节运行环境初始化的时候在mon ...