POJ 2318
来源:互联网 发布:站长域名查询 编辑:程序博客网 时间:2024/06/05 02:02
二分
#include <iostream>using namespace std;const int maxn=5010;int Ui[maxn],Li[maxn],dx[maxn],dy;int amount[maxn];int m,n,x1,y1,x2,y2;int bsearch(int xj,int yj){int low=-1,high=m,mid;while(high-low>1){mid=(high+low)/2;if((dy*(xj-Ui[mid])-dx[mid]*(yj-y1))<0)high=mid;elselow=mid;}return high;}int main(){while(scanf("%d",&m)&&m!=0){cin>>n>>x1>>y1>>x2>>y2;dy=y1-y2;int i;for(i=0;i<m;i++){cin>>Ui[i]>>Li[i];dx[i]=Ui[i]-Li[i];amount[i]=0;}amount[i]=0;int xj,yj,outcome;for(i=0;i<n;i++){cin>>xj>>yj;outcome=bsearch(xj,yj);amount[outcome]++;}for(i=0;i<=m;i++){cout<<i<<": "<<amount[i]<<endl;}cout<<endl;}return 0;}
- poj 2318 poj 2398
- poj 2318
- POJ 2318
- poj 2318
- POJ 2318
- poj 2318
- poj.2318
- poj 2318
- poj 2318
- POJ-2318
- poj 2318
- POJ 2318
- POJ 2318 几何 POJ 2398
- POJ 2318 TOYS && POJ 2398 Toy Storage
- 【计算几何】POJ 2318 & POJ 2398
- POJ 2318 TOYS || POJ 2398 Toy Storage
- POJ 2318 TOYS
- poj 2318 TOYS
- php+mysql+apache环境搭建
- 【phpcms-v9】如何实现在含有子栏目的栏目下添加内容?
- linux闲话&&FHS标准下linux目录结构
- Linux下的软件安装与卸载
- 学习 java annotation
- POJ 2318
- 设计模式六大原则(1):单一职责原则
- Linux帐号管理[上]--4个配置文件
- Jquery调用C# WebService方法
- Linux帐号管理[中]--用户管理
- socket的send、recv阻塞设置阻塞超时时间
- android如何启动线程
- 一枕落花香
- 基于Extjs开发不允许为空的文本框提示及相应的验证错误提示