题意:就是给了m个点,落在n+1个区域中,问各个区域有多少个点。

/*
对于每个玩具,二分其所在的区间,然后用叉积判断。
但是我觉得枚举好像时间复杂度也可以。
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#define N 5010
using namespace std;
int n,m,cnt[N];
struct Point{
int x,y;
};
struct Line{
Point a,b;
}line[N];
int crs(Point p1,Point p2,Point p0){
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
void search(Point p){
int l=,r=n;
while(l<r){
int mid=l+r>>;
if(crs(p,line[mid].a,line[mid].b)<) r=mid;
else l=mid+;
}
if(crs(p,line[l].a,line[l].b)<) cnt[l]++;
else cnt[l+]++;
}
int main(){
int x1,y1,x2,y2;
while(scanf("%d",&n)&&n){
memset(cnt,,sizeof(cnt));
scanf("%d%d%d%d%d",&m,&x1,&y1,&x2,&y2);
for(int i=;i<=n;i++){
int t1,t2;scanf("%d%d",&t1,&t2);
line[i].a.x=t1;
line[i].a.y=y1;
line[i].b.x=t2;
line[i].b.y=y2;
}
for(int i=;i<=m;i++){
Point p;
scanf("%d%d",&p.x,&p.y);
search(p);
}
for(int i=;i<=n+;i++)
printf("%d: %d\n",i-,cnt[i]);
printf("\n");
}
return ;
}

TOYS(poj 2318)的更多相关文章

  1. A - TOYS(POJ - 2318) 计算几何的一道基础题

    Calculate the number of toys that land in each bin of a partitioned toy box. 计算每一个玩具箱里面玩具的数量 Mom and ...

  2. (POJ 2318)TOYS 向量叉积

    题目链接:http://poj.org/problem?id=2318 #include<stdio.h> #include<cstdlib> #include<cstr ...

  3. 叉积(POJ - 2318 )

    题目链接:https://cn.vjudge.net/contest/276358#problem/A 题目大意:给你一个矩阵的左上角和右下角,然后n个竖杠,这n个竖杠将这个矩阵分成n+1个方块,给你 ...

  4. POJ 2318 TOYS(叉积+二分)

    题目传送门:POJ 2318 TOYS Description Calculate the number of toys that land in each bin of a partitioned ...

  5. 01背包问题:Charm Bracelet (POJ 3624)(外加一个常数的优化)

    Charm Bracelet    POJ 3624 就是一道典型的01背包问题: #include<iostream> #include<stdio.h> #include& ...

  6. Scout YYF I(POJ 3744)

    Scout YYF I Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5565   Accepted: 1553 Descr ...

  7. 广大暑假训练1(poj 2488) A Knight's Journey 解题报告

    题目链接:http://vjudge.net/contest/view.action?cid=51369#problem/A   (A - Children of the Candy Corn) ht ...

  8. Games:取石子游戏(POJ 1067)

    取石子游戏 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37662   Accepted: 12594 Descripti ...

  9. BFS 或 同余模定理(poj 1426)

    题目:Find The Multiple 题意:求给出的数的倍数,该倍数是只由 1与 0构成的10进制数. 思路:nonzero multiple  非零倍数  啊. 英语弱到爆炸,理解不了题意... ...

随机推荐

  1. android开发学习 ------- 【转】EventBus的学习理解

    EventBus是一个Android端优化的publish/subscribe消息总线,简化了应用程序内各组件间.组件与后台线程间的通信. 比如请求网络,等网络返回时通过Handler或Broadca ...

  2. SpringBoot 2.x (8):模板引擎

    SpringBoot中有很多的starter:本质是多个JAR包集合 比如我们常用的: <dependency> <groupId>org.springframework.bo ...

  3. iframe及其引出的页面跳转问题

    前提:在前一段的工作中碰到了一些页面跳转,子页面跳到父页面上的等等问题,当时页面总是跳不对,或者跳错,要不就是不需要重新打开窗口,却又重新打开一个了,特此搜寻网上各大博客论坛,加上项目经验整理一篇文章 ...

  4. [BZOJ1045][HAOI2008]糖果传递 数学

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1045 我们假设每一个小朋友的代价为$x[i]$,每一次都从前面一个小朋友那里拿,这种贪心跟 ...

  5. HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported问题解决

    今天创建springboot项目的时候添加完依赖启动出现了这个错误 -- :: --- [ main] o.h.v.m.ParameterMessageInterpolator : HV000184: ...

  6. Linux环境下手动配置sbt

    一.下载sbt安装包 从sbt官网下载地址:http://www.scala-sbt.org/download.html下载安装包,以sbt-0.13.13.tgz为例. 二.安装 1.将下载的二进制 ...

  7. react基础语法(三)组件的创建和复合组件

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. NYOJ 题目42 一笔画问题

    一笔画问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 zyc从小就比较喜欢玩一些小游戏,其中就包括画一笔画,他想请你帮他写一个程序,判断一个图是否能够用一笔画下 ...

  9. Apache安装和文件配置

    Apache和Tomcat的区别是:静态文件和动态页面,C++和Java的区别. 对比.

  10. 环球影城母公司:务必阻止复仇者和 X 战警团聚

    今日导读 去年 12 月,迪士尼宣布收购 21 世纪福克斯后,许多漫威粉丝们马上欢呼:复仇者终于可以和 X 战警团聚了!然而,超级英雄大团圆这个美好景象恐怕不会那么容易实现.就在近日,环球影城母公司— ...