跨产品的利用率推断点线段向左或向右,然后你可以2分钟

代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; const int N = 5005; int n, m, x1, y1, x2, y2; struct Point {
int x, y;
Point() {}
Point(int x, int y) {
this->x = x;
this->y = y;
}
}; typedef Point Vector; Vector operator - (Vector A, Vector B) {
return Vector(A.x - B.x, A.y - B.y);
} struct Seg {
Point a, b;
Seg() {}
Seg(Point a, Point b) {
this->a = a;
this->b = b;
}
} seg[N]; int ans[N]; int Cross(Vector A, Vector B) {return A.x * B.y - A.y * B.x;} void gao(Point p) {
int l = 0, r = n;
while (l < r) {
int mid = (l + r) / 2;
if (Cross(seg[mid].a - p, seg[mid].b - p) < 0) r = mid;
else l = mid + 1;
}
ans[l]++;
} int main() {
while (~scanf("%d", &n) && n) {
memset(ans, 0, sizeof(ans));
scanf("%d%d%d%d%d", &m, &x1, &y1, &x2, &y2);
int x, y;
for (int i = 0; i < n; i++) {
scanf("%d%d", &x, &y);
seg[i] = Seg(Point(x, y1), Point(y, y2));
}
for (int i = 0; i < m; i++) {
scanf("%d%d", &x, &y);
gao(Point(x, y));
}
for (int i = 0; i <= n; i++)
printf("%d: %d\n", i, ans[i]);
printf("\n");
}
return 0;
}

最新文章

  1. Hadoop学习笔记—9.Partitioner与自定义Partitioner
  2. Nginx重新编译添加模块
  3. iOS UITableView点击按钮滚到顶部
  4. JAVA的JVM虚拟机工作原理.V.1.0.0
  5. UVA 12904 Load Balancing 暴力
  6. 触摸屏网站开发系列(一)-ios web App应用程序(ios meta)
  7. 李洪强iOS开发-网络新闻获取数据思路回顾
  8. SpringMVC单文件上传、多文件上传、文件列表显示、文件下载(转)
  9. 基于 Vue 全家桶制作的移动端音乐 WebApp
  10. Red Hat 7.0 DNS服务配置笔记
  11. 服务器开发之CGI后门
  12. Leetcode_118_Pascal&#39;s Triangle
  13. [微信跳转链接]之WAP浏览器跳转微信指定页面,微信跳转链接
  14. Java基础之一
  15. CentOS 7 用firewall-cmd来开放端口
  16. 22.LinkedList
  17. symmfony
  18. spring applicationContext.xml
  19. maven scope和项目发布需要注意的地方
  20. Python面向对象高级编程:@property--把方法变为属性

热门文章

  1. @produces在spring mvc中是什么意思
  2. C语言指针和数组知识总结(下)
  3. MYSQL获取自增主键【4种方法】
  4. pssh,pscp,pslurp使用实践
  5. Java内部类——局部内部类
  6. Qt遍历图片文件
  7. timesetevent与timekillevent的用法
  8. Eclipse和PyDev搭建完美Python开发环境(Windows篇)(转)
  9. android——写xml
  10. .net面试题大全(有答案)