POJ 2318 计算几何大水题
来源:互联网 发布:135 139端口关闭 编辑:程序博客网 时间:2024/04/30 00:50
暴力一下 O(MN)
#include<cstdio>#include<cstring>#include<cmath>const int maxn = 5100;const double eps = 1e-12;int dcmp(double x){ return fabs(x) < eps ? 0 : (x < 0 ? -1 : 1);}struct Point{ double x, y; Point(){} Point(double _x, double _y):x(_x),y(_y){} void input(){scanf("%lf%lf", &x, &y);} void set(double a, double b){x = a; y = b;}};typedef Point Vector;Vector operator - (const Vector &a, const Vector &b){ return Vector(a.x - b.x, a.y - b.y);}double operator ^ (const Vector &a, const Vector &b){ return a.x * b.y - a.y * b.x;}Point u[maxn], d[maxn];int cnt[maxn];int main(){// freopen("in.txt", "r", stdin); int n, m; Point A, B, C; while(scanf("%d%d", &n, &m) == 2 && n){ memset(cnt, 0, sizeof(cnt)); A.input(); B.input(); u[0].set(A.x, A.y); d[0].set(A.x, B.y); for(int i = 1; i <= n; i++){ double t; u[i].set((scanf("%lf", &t), t), A.y); d[i].set((scanf("%lf", &t), t), B.y); } u[n+1].set(B.x, A.y); d[n+1].set(B.x, B.y); for(int i = 0; i < m; i++){ C.input(); for(int i = 0; i <= n; i++) if(dcmp((d[i]-u[i])^(C-u[i])) == 1 && dcmp((d[i+1]-u[i+1])^(C-d[i+1])) == -1){ cnt[i]++; break; } } for(int i = 0; i <= n; i++) printf("%d: %d\n", i, cnt[i]); printf("\n"); } return 0;}
0 0
- POJ 2318 计算几何大水题
- POJ 2318(计算几何 )
- POJ 2318 计算几何 叉积水题
- poj 1656 大水题
- POJ 2328 大水题
- POJ 2318 计算几何 叉积
- POJ 2318 2398 计算几何
- poj-2318-TOYS-计算几何
- POJ 2318 计算几何+二分
- POJ 2318 TOYS(计算几何)
- poj 2318(计算几何)
- poj 2318 TOYS (计算几何)
- POJ 2318 计算几何 题解
- 计算几何--POJ--2318--TOYS
- POJ 2318 TOYS <计算几何>
- poj计算几何题推荐
- 【计算几何】POJ 2318 & POJ 2398
- POJ 2318 TOYS 计算几何 入门题 叉积 + 二分
- npm设置仓库
- 解决:ubuntu16.04下修改mysql字符集为utf8却找不到配置文件的问题
- VHDL inout与buffer
- jquery怎么在header中设置请求信息
- struts模型驱动和属性驱动
- POJ 2318 计算几何大水题
- 省市县三级联动
- cocoscreate 官方例子说明 02_ui_01_widget_AutoResize by:adady
- 粘滞位
- Android绘制选手实力图
- android虚席总结(16.08.26)Activity的生命周期
- AOJ 455 POJ 1088 滑雪 dfs + 记忆化搜索
- Rxjava 概览
- 《虚拟化技术原理与实现》读书笔记之前序(一)