博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ2398 Toy Storage
阅读量:6946 次
发布时间:2019-06-27

本文共 3364 字,大约阅读时间需要 11 分钟。

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 5523   Accepted: 3288

Description

Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave Reza a rectangular box to put his toys in. Unfortunately, Reza is rebellious and obeys his parents by simply throwing his toys into the box. All the toys get mixed up, and it is impossible for Reza to find his favorite toys anymore. 
Reza's parents came up with the following idea. They put cardboard partitions into the box. Even if Reza keeps throwing his toys into the box, at least toys that get thrown into different partitions stay separate. The box looks like this from the top: 
We want for each positive integer t, such that there exists a partition with t toys, determine how many partitions have t, toys.

Input

The input consists of a number of cases. The first line consists of six integers n, m, x1, y1, x2, y2. The number of cardboards to form the partitions is n (0 < n <= 1000) and the number of toys is given in m (0 < m <= 1000). The coordinates of the upper-left corner and the lower-right corner of the box are (x1, y1) and (x2, y2), respectively. The following n lines each consists of two integers Ui Li, indicating that the ends of the ith cardboard is at the coordinates (Ui, y1) and (Li, y2). You may assume that the cardboards do not intersect with each other. The next m lines each consists of two integers Xi Yi specifying where the ith toy has landed in the box. You may assume that no toy will land on a cardboard. 
A line consisting of a single 0 terminates the input.

Output

For each box, first provide a header stating "Box" on a line of its own. After that, there will be one line of output per count (t > 0) of toys in a partition. The value t will be followed by a colon and a space, followed the number of partitions containing t toys. Output will be sorted in ascending order of t for each box.

Sample Input

4 10 0 10 100 020 2080 8060 6040 405 1015 1095 1025 1065 1075 1035 1045 1055 1085 105 6 0 10 60 04 315 303 16 810 102 12 81 55 540 107 90

Sample Output

Box2: 5Box1: 42: 1

Source

 

数学 几何

比较有趣

对于每个点,二分选择线段来夹逼它,得出它所在的区间,统计答案。

 

1 /*by SilverN*/ 2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 using namespace std; 9 const double eps=1e-8;10 const int mxn=1010;11 int read(){12 int x=0,f=1;char ch=getchar();13 while(ch<'0' || ch>'9'){ if(ch=='-')f=-1;ch=getchar();}14 while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}15 return x*f;16 }17 struct Point{18 double x,y;19 Point operator + (Point rhs){ return (Point){x+rhs.x,y+rhs.y};}20 Point operator - (Point rhs){ return (Point){x-rhs.x,y-rhs.y};}21 Point operator * (double len){ return (Point){x*len,y*len};}22 double operator *(Point rhs){ return x*rhs.x+y*rhs.y;}23 }a[mxn],b[mxn],p;24 struct Line{25 double u,l;26 bool operator < (Line rhs)const { return u
a[n+1].x || p.y>a[0].y || p.y
>1;65 if(Cross(a[mid]-b[mid],p-b[mid])>0)r=mid;66 else l=mid;67 68 }69 // printf("l:%d\n",l);70 ++cnt[l];71 }72 for(i=0;i<=n;i++){73 if(cnt[i])w[cnt[i]]++;74 }75 printf("Box\n");76 for(i=1;i<=m;i++){77 if(w[i]){78 printf("%d: %d\n",i,w[i]);79 }80 }81 }82 return 0;83 }

 

转载于:https://www.cnblogs.com/SilverNebula/p/6486236.html

你可能感兴趣的文章
爬虫框架webmagic与spring boot的结合使用--转
查看>>
安防工程商必须知道的PoE供电真相
查看>>
使用 Python & Flask 实现 RESTful Web API
查看>>
R语言学习 第二篇:矩阵和数组
查看>>
在服务器端png转jpg
查看>>
MarkDown 编辑数学公式
查看>>
Docker(五):Docker 三剑客之 Docker Machine
查看>>
SQLite中的WHERE子句
查看>>
移动端底部input被弹出的键盘遮挡
查看>>
dubbo 部分 配置的关系-dubbo github 官方案例
查看>>
SpringBoot JMS(ActiveMQ) 使用实践
查看>>
如何用Tensorflow训练模型成pb文件和和如何加载已经训练好的模型文件
查看>>
Mysql系列九:使用zookeeper管理远程Mycat配置文件、Mycat监控、Mycat数据迁移(扩容)...
查看>>
『转载』使用DotMSN 2.0开发MSN机器人
查看>>
1489: 数字排列 (DFS)
查看>>
china-pub满48元即刻享受免运费
查看>>
分布式系统工程实现:GFS&amp;Bigtable设计的优势,互联网营销
查看>>
用WPF实现屏幕文字提示,徐汇区网站设计
查看>>
在tomcat中配置连接池
查看>>
矩阵乘法-并行计算
查看>>