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 ;
}

最新文章

  1. Hibernate(5)—— 联合主键 、一对一关联关系映射(xml和注解) 和 领域驱动设计
  2. 【Android】Android应用安装失败及无法打开
  3. Java多线程编程核心技术---拾遗增补
  4. ccc 单点触控
  5. ubuntu实用技巧
  6. POJ3252——Round Number(组合数学)
  7. Linux命令-dd
  8. spoj 375 Query on a tree(树链剖分,线段树)
  9. 在windows10+word2010中完美使用北大方正word公式输入法总结
  10. 黑马程序员-------.net基础知识二
  11. cf459B Pashmak and Flowers
  12. lucene的多种搜索2-SpanQuery
  13. POJ1741Tree [点分治]【学习笔记】
  14. CodeForces - 796D Police Stations bfs
  15. django2.0升级日记
  16. git解析日志常用命令
  17. ABBYY Cup 3.0G3. Good Substrings
  18. elast alert
  19. 16 多校 8 Ball (贪心排序)很巧妙的思路啊~
  20. C语言基础:结构体 分类: iOS学习 c语言基础 2015-06-10 21:47 28人阅读 评论(0) 收藏

热门文章

  1. 回顾PMP考试
  2. 使用windows的fsutil命令创建指定大小及类型的测试文件
  3. [译] 用win7自带工具找出svchost.exe的CPU使用率达到100%的元凶
  4. Django创建第一个应用
  5. TebsorFlow低阶API(五)—— 保存和恢复
  6. In line copy and paste to system clipboard
  7. WEB 前端模块化,读文笔记
  8. 字典(trie)树--从入门到入土
  9. Spring中RestTemplate的使用方法
  10. 查询SYS_ORG_TB树的层级