http://poj.org/problem?id=2398

这道题和上一道TOYS是一样的   就是输出不一样  还有就是这个给的是乱序  你要先对挡板排序

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <math.h>
#include <ctype.h> using namespace std;
#define memset(a,b) memset(a,b,sizeof(a))
#define N 5500
typedef long long ll; struct node
{
int x, y, v;
}p[N],u[N];
int y2; int cmp(const void *a,const void *b)
{
struct node *c, *f;
c=(struct node *)a;
f=(struct node *)b;
return c->x-f->x;
} int Find(int nx,int ny,int l,int r)
{
if(l==r-)
return l;
int mid=(l+r)/;
node d;
d.x=nx-p[mid].v;
d.y=ny-y2;
if((d.x*p[mid].y)-(d.y*p[mid].x)>)
{
l=mid;
r=r;
return Find(nx,ny,l,r);
}
else if((d.x*p[mid].y)-(d.y*p[mid].x)<)
{
l=l;
r=mid;
return Find(nx,ny,l,r);
}
return ;
} int main()
{
int n,m,x1,x2,y1,a[N];
while(scanf("%d",&n),n)
{
memset(a,);
scanf("%d %d %d %d %d",&m,&x1,&y1,&x2,&y2);
p[].x=x1;
p[].y=y2;
p[].v=x1;
for(int i=;i<=n;i++)
{
scanf("%d %d",&u[i].x,&u[i].y);
}
qsort(u+,n,sizeof(u[]),cmp);
for(int i=;i<=n;i++)
{
p[i].x=u[i].x-u[i].y;
p[i].y=y1-y2;
p[i].v=u[i].y;
}
p[n+].x=x2;
p[n+].y=y1;
p[n+].v=x2;
int k,v;
for(int i=;i<m;i++)
{
scanf("%d %d",&k,&v);
int aa=Find(k,v,,n+);
a[aa]++;
}
int ans[N];
memset(ans,);
for(int i=;i<=n;i++)
{
if(a[i])
{
ans[a[i]]++;
}
}
printf("Box\n");
for(int i=;i<=n;i++)
{
if(ans[i])
printf("%d: %d\n",i,ans[i]);
}
}
return ;
}

Toy Storage--POJ2398(计算几何)的更多相关文章

  1. POJ 2398 Toy Storage(计算几何,叉积判断点和线段的关系)

    Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3146   Accepted: 1798 Descr ...

  2. [POJ2398]Toy Storage(计算几何,二分,判断点在线段的哪一侧)

    题目链接:http://poj.org/problem?id=2398 思路RT,和POJ2318一样,就是需要排序,输出也不一样.手工画一下就明白了.注意叉乘的时候a×b是判断a在b的顺时针还是逆时 ...

  3. poj2398 Toy Storage 计算几何,叉积,二分

    poj2398 Toy Storage 链接 poj 题目大意 这道题的大概意思是先输入6个数字:n,m,x1,y1,x2,y2.n代表卡片的数量,卡片竖直(或倾斜)放置在盒内,可把盒子分为n+1块区 ...

  4. 2018.07.04 POJ 2398 Toy Storage(二分+简单计算几何)

    Toy Storage Time Limit: 1000MS Memory Limit: 65536K Description Mom and dad have a problem: their ch ...

  5. poj 2398 Toy Storage(计算几何)

    题目传送门:poj 2398 Toy Storage 题目大意:一个长方形的箱子,里面有一些隔板,每一个隔板都可以纵切这个箱子.隔板将这个箱子分成了一些隔间.向其中扔一些玩具,每个玩具有一个坐标,求有 ...

  6. poj 2398 Toy Storage(计算几何 点线关系)

    Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4588   Accepted: 2718 Descr ...

  7. POJ 2398 - Toy Storage 点与直线位置关系

    Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5439   Accepted: 3234 Descr ...

  8. POJ 2318 TOYS && POJ 2398 Toy Storage(几何)

    2318 TOYS 2398 Toy Storage 题意 : 给你n块板的坐标,m个玩具的具体坐标,2318中板是有序的,而2398无序需要自己排序,2318要求输出的是每个区间内的玩具数,而231 ...

  9. Toy Storage

    Toy Storage 题型与2318 TOYS一样,注意要对线段排序,现在模板又更新了~~ #include<iostream> #include<cstdio> #incl ...

  10. POJ 2398 Toy Storage (叉积判断点和线段的关系)

    题目链接 Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4104   Accepted: 2433 ...

随机推荐

  1. C#读取web.config配置文件内容

    1.对配置文件的访问. 方法一: string myConn =System.Configuration.ConfigurationManager.ConnectionStrings["sq ...

  2. react基础语法(四) state学习

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

  3. 接口自动化- 基于 Python

    准备工作 这部分其实在谷歌或者百度上搜索下就可以完成的,可是我就是想再啰嗦一遍,说不定有比我更懒的同学呢哈哈~ 第一步 Python的安装配置 打开官网: https://www.python.org ...

  4. 目录下 shift 右键菜单 打开cmd 或者在 地址栏输入cmd 回车进入cmd

    目录下 shift 右键菜单 打开cmd 或者在 地址栏输入cmd 回车进入cmd

  5. Android N requires the IDE to be running with Java 1.8 or later

      Android Studio需要两个JDK: ide jdk和project jdk: 前者是IDE本身运行使用的JDK. 后者用于编译Java代码 Project JDK 可以通过file-&g ...

  6. 设计模式:命令模式(Command Pattern)

    问题 某个类中需要定义一个方法,该方法要实现的功能不确定的,需要等到程序执行该方法的时候才确定下来. 例如:定义一个计算数组的方法,可能需要遍历输出数组,也有可能是需要对数组中元素求和. 解决方案 按 ...

  7. 配置maven报错 the java_home environment variable is not defined correctly ......

    the java_home environment variable is not defined correctly This environment variable is needed to r ...

  8. 888. Fair Candy Swap@python

    Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Ali ...

  9. 洛谷——P1627 [CQOI2009]中位数

    P1627 [CQOI2009]中位数 给出1~n的一个排列,统计该排列有多少个长度为奇数的连续子序列的中位数是b.中位数是指把所有元素从小到大排列后,位于中间的数. 中位数的题目有关统计的话,可以转 ...

  10. SDOI2011 拦截导弹

    题目描述 题解: 对于第一问,我们求二维LIS即可; 对于第二问,我们可以记录向前最长长度,向前最长方案数,向后最长长度,向后最长方案数. 其实改改树状数组即可. 还有,方案数一定要开double. ...