poj2318 水题(二分+叉积)
题目链接:http://poj.org/problem?id=2318
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
const int maxn = ;
const int maxe = ;
const int INF = 0x3f3f3f;
const double eps = 1e-;
const double PI = acos(-1.0); struct Point{
double x,y;
Point(double x=, double y=) : x(x),y(y){ } //构造函数
};
typedef Point Vector; Vector operator + (Vector A , Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator - (Vector A , Vector B){return Vector(A.x-B.x,A.y-B.y);}
Vector operator * (Vector A , double p){return Vector(A.x*p,A.y*p);}
Vector operator / (Vector A , double p){return Vector(A.x/p,A.y/p);} bool operator < (const Point& a,const Point& b){
return a.x < b.x ||( a.x == b.x && a.y < b.y);
}
int dcmp(double x){
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
bool operator == (const Point& a, const Point& b){
return dcmp(a.x - b.x) == && dcmp(a.y - b.y) == ;
} double Dot(Vector A, Vector B){ return A.x*B.x + A.y*B.y; }
double Cross(Vector A, Vector B) { return A.x*B.y - A.y * B.x; }
double Length(Vector A) { return sqrt(Dot(A,A)); } /******************************分割线*******************************/ Point P[maxn][];
int N,M; int main()
{
//freopen("E:\\acm\\input.txt","r",stdin);
while(scanf("%d",&N)== && N){
scanf("%d",&M);
double x1,y1,x2,y2;
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
P[][] = Point(x1,y2); P[][] = Point(x1,y1);
P[N+][] = Point(x2,y2); P[N+][] = Point(x2,y1);
for(int i=;i<=N;i++){
double Ui,Li;
scanf("%lf %lf",&Ui,&Li);
P[i][] = Point(Li,y2); P[i][] = Point(Ui,y1);
}
int num[maxn];
memset(num,,sizeof(num));
for(int i=;i<=M;i++){
Point A;
scanf("%lf %lf",&A.x,&A.y);
int L=, R=N+;
while(L < R-){
int mid = L + (R-L)/;
if(dcmp(Cross(P[mid][]-P[mid][],A-P[mid][])) > ) R = mid;
else L = mid;
}
num[L]++;
}
for(int i=;i<=N;i++){
printf("%d: %d\n",i,num[i]);
}
printf("\n");
}
}
poj2318 水题(二分+叉积)的更多相关文章
- UVaLive 3971 Assemble (水题二分+贪心)
题意:你有b元钱,有n个配件,每个配件有各类,品质因子,价格,要每种买一个,让最差的品质因子尽量大. 析:很简单的一个二分题,二分品质因子即可,每次计算要花的钱的多少,每次尽量买便宜且大的品质因子. ...
- hdu - 6276,2018CCPC湖南全国邀请赛A题,水题,二分
题意: 求H的最大值, H是指存在H篇论文,这H篇被引用的次数都大于等于H次. 思路:题意得, 最多只有N遍论文,所以H的最大值为N, 常识得知H的最小值为0. 所以H的答案在[0,N]之间,二分 ...
- POJ 水题(刷题)进阶
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...
- CF 628A --- Tennis Tournament --- 水题
CF 628A 题目大意:给定n,b,p,其中n为进行比赛的人数,b为每场进行比赛的每一位运动员需要的水的数量, p为整个赛程提供给每位运动员的毛巾数量, 每次在剩余的n人数中,挑选2^k=m(m & ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- UPC 2959: Caoshen like math 这就是个水题
http://acm.upc.edu.cn/problem.php?id=2959 这就是个水题,之所以要写这个题是感觉很有纪念意义 用力看就是盲……23333333333333333 这个题就是最小 ...
- BZOJ USACO 银组 水题集锦
最近刷银组刷得好欢快,好像都是水题,在这里吧他们都记录一下吧(都是水题大家一定是道道都虐的把= =)几道比较神奇的题到时再列出来单独讲一下吧= =(其实我会说是BZOJ蹦了无聊再来写的么 = =) [ ...
- Atcoder 水题选做
为什么是水题选做呢?因为我只会水题啊 ( 为什么是$Atcoder$呢?因为暑假学长来讲课的时候讲了三件事:不要用洛谷,不要用dev-c++,不要用单步调试.$bzoj$太难了,$Topcoder$整 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
随机推荐
- 解决UITabeleViewCell的分割线不能铺满问题
-(void)viewDidLayoutSubviews { if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)] ...
- C语言字符串库函数的实现
1.strlen(字符串的长度) size_t Strlen(const char* str) { assert(str); ;; ++i) { if (str[i] == '\0') return ...
- js操作Cookie,实现历史浏览记录
/** * history_teacher.jsp中的js,最近浏览名师 * @version: 1.0 * @author: mingming */ $(function(){ getHistory ...
- 阻止文件不被上传到iCloud-b
有空用下 http://www.cocoachina.com/bbs/read.php?tid=86244 http://www.ooso.net/archives/617 http://blog.c ...
- linux学习笔记---一些有趣的命令
一 在说链接之前我们哈需要说明一个东西,就是inode,一个文件的名字可以有多个,但是inode里的i-number却只有一个,(inode是一个数据结构,里面存放文件的各种属性,属主,属组,权限,大 ...
- 转:简单介绍 P3P 技术
原文来自于:http://blog.csdn.net/ghj1976/article/details/4889219 以 Internet Explorer 为例,默认情况下,IE的隐私策略如下图所设 ...
- 【译】UI设计基础(UI Design Basics)--iOS应用解析(iOS App Anatomy)(三)
2.1 iOS应用解析(iOS App Anatomy) 几乎所有的iOS应用都会用到UIKit框架中的组件.了解这些基础组件的名称,角色,功能可以帮你在应用界面设计时做出更好的决策. UIKit提 ...
- hadoop各版本下载
http://hadoop.apache.org/ Download Hadoop from the release page. http://hadoop.apache.org/releases.h ...
- BZOJ 3106 棋盘游戏
Description 一个\(n \times n(n \le 2)\)棋盘上有黑白棋子各一枚.游戏者A和B轮流移动棋子,A先走. A的移动规则:只能移动白棋子.可以往上下左右四个方向之一移动一格. ...
- J2EE和EJB有什么关系?
其实j2EE就是java的企业版,与javaSE(标准版)有是有区别的,所以运行环境会有差异(简单点可以说,这是两组不同的接口),我们一般所熟悉的tomcat仅仅只实现了j2ee的一小部分规范,它只是 ...