Toy Storage--POJ2398(计算几何)
2024-10-20 09:22:46
http://poj.org/problem?id=2398
这道题和上一道TOYS是一样的 就是输出不一样 还有就是这个给的是乱序 你要先对挡板排序
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <math.h>
#include <ctype.h> using namespace std;
#define memset(a,b) memset(a,b,sizeof(a))
#define N 5500
typedef long long ll; struct node
{
int x, y, v;
}p[N],u[N];
int y2; int cmp(const void *a,const void *b)
{
struct node *c, *f;
c=(struct node *)a;
f=(struct node *)b;
return c->x-f->x;
} int Find(int nx,int ny,int l,int r)
{
if(l==r-)
return l;
int mid=(l+r)/;
node d;
d.x=nx-p[mid].v;
d.y=ny-y2;
if((d.x*p[mid].y)-(d.y*p[mid].x)>)
{
l=mid;
r=r;
return Find(nx,ny,l,r);
}
else if((d.x*p[mid].y)-(d.y*p[mid].x)<)
{
l=l;
r=mid;
return Find(nx,ny,l,r);
}
return ;
} int main()
{
int n,m,x1,x2,y1,a[N];
while(scanf("%d",&n),n)
{
memset(a,);
scanf("%d %d %d %d %d",&m,&x1,&y1,&x2,&y2);
p[].x=x1;
p[].y=y2;
p[].v=x1;
for(int i=;i<=n;i++)
{
scanf("%d %d",&u[i].x,&u[i].y);
}
qsort(u+,n,sizeof(u[]),cmp);
for(int i=;i<=n;i++)
{
p[i].x=u[i].x-u[i].y;
p[i].y=y1-y2;
p[i].v=u[i].y;
}
p[n+].x=x2;
p[n+].y=y1;
p[n+].v=x2;
int k,v;
for(int i=;i<m;i++)
{
scanf("%d %d",&k,&v);
int aa=Find(k,v,,n+);
a[aa]++;
}
int ans[N];
memset(ans,);
for(int i=;i<=n;i++)
{
if(a[i])
{
ans[a[i]]++;
}
}
printf("Box\n");
for(int i=;i<=n;i++)
{
if(ans[i])
printf("%d: %d\n",i,ans[i]);
}
}
return ;
}
最新文章
- Hibernate(5)—— 联合主键 、一对一关联关系映射(xml和注解) 和 领域驱动设计
- 【Android】Android应用安装失败及无法打开
- Java多线程编程核心技术---拾遗增补
- ccc 单点触控
- ubuntu实用技巧
- POJ3252——Round Number(组合数学)
- Linux命令-dd
- spoj 375 Query on a tree(树链剖分,线段树)
- 在windows10+word2010中完美使用北大方正word公式输入法总结
- 黑马程序员-------.net基础知识二
- cf459B Pashmak and Flowers
- lucene的多种搜索2-SpanQuery
- POJ1741Tree [点分治]【学习笔记】
- CodeForces - 796D Police Stations bfs
- django2.0升级日记
- git解析日志常用命令
- ABBYY Cup 3.0G3. Good Substrings
- elast alert
- 16 多校 8 Ball (贪心排序)很巧妙的思路啊~
- C语言基础:结构体 分类: iOS学习 c语言基础 2015-06-10 21:47 28人阅读 评论(0) 收藏