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 ...
随机推荐
- Cordova框架基本原理
最近在做混编项目,也是从项目里开始接触Cordova框架,网上很多帖子都总结的很好,我还是要总结一下,便于加深一下. Cordova框架是一个可以让JS与原生代码(包括 Android 的 java, ...
- javascript继承--原型链的 继承
作者的话:原型链是JavaScript中相当重要的一个知识点,这里我使用了函数结构图,来帮助我更好的理解 /* 原型链继承方式: 通过改变一个对象的原型对象的指向来继承另一个对象 原理: 我们知道,一 ...
- HTML5周记(二)
大家好,很高兴又跟大家见面了!本周更新博主将给大家带来更精彩的HTML5技术分享,通过本周的学习,可实现大部分的网页制作.以下为本次更新内容. 第四章 css盒模型 <!DOCTYPE html ...
- 通用数据库帮助类DBHelper(含log日志信息实时记录)
项目需要,需要一个通用的数据库操作类,增删改查.事务.存储过程.日志记录都要有,于是在已有的帮助类上做了一些改进,并将log4j的.NET版--log4net嵌入其中记录sql的执行环境和状态. 用起 ...
- Oeacle创建表空间
/*第1步:创建临时表空间 */ create temporary tablespace user_temp tempfile 'D:\oracle\oradata\Oracle9i\user_tem ...
- css 样式表 基础 样式
1大小 width 宽度 height 高度 2 背景 background-color 背景色 background-image:url(图片位置) 背景图片 background-repeat: ...
- [Linux] PHP程序员玩转Linux系列-Linux和Windows安装nginx
1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...
- 奇葩问题:同样的字符串equal为false
问题:什么情况下 "同样" 的字符串会不equal呢?例如 "a".equal("a") => false 在你看来,这可能是个 ...
- Python可视化学习(2):Matplotlib快速绘图基础
Matplotlib将大部分的绘图对象都封装成为对象,故理论上所有的图表元素(如Line2D, Text,Label等)都是对象,都可以将其在图表中提取出来并配置实例的属性.同时,Matplotlib ...
- Robotframe work学习之初(二)
一.F5帮助 Robot Framework 并没有像其它框架一样提供一份完整的 API 文档,所以,我们没办法通过官方 API文档进行习.RIDE 提供了 F5 快捷键来打开帮助文档. search ...