hdu 3952
因为一个小错 不过 好不爽........
- #include <iostream>
- #include <fstream>
- using namespace std;
- struct Node
- {
- int x, y;
- };
- class shap
- {
- public:
- int num;
- Node dian[22];
- } q[22];
- double getk(int x1, int y1, int x2, int y2)
- {
- return (double)(y1-y2)/(double)(x1-x2);
- }
- double esp = 1e-7;
- int main(void)
- {
- // freopen("1.txt", "r", stdin);
- int kase;
- cin>>kase;
- int n;
- int count = 1;
- while(kase-- && cin>>n)
- {
- int m;
- for(int i = 0; i < n; i++)
- {
- cin>>m;
- q[i].num = m;
- for(int j = 0; j < m; j++)
- cin>>q[i].dian[j].x>>q[i].dian[j].y;
- }
- if(n <= 2)
- {
- printf("Case %d: %d\n", count++, n);
- continue;
- }
- int _max = 2;
- for(int i = 0; i < n; i++)
- {
- for(int j = i+1; j < n; j++)
- {
- for(int k = 0; k < q[i].num; k++)
- {
- for(int g = 0; g < q[j].num; g++)
- {
- int a = q[i].dian[k].x;
- int b = q[i].dian[k].y;
- int c = q[j].dian[g].x;
- int d = q[j].dian[g].y;
- int cnt = 2;
- if(a == c)
- {
- for(int ii = 0; ii < n; ii++)
- {
- if(ii == i || ii == j)
- continue;
- int x = a;
- int ok = q[ii].dian[0].x < x? -1:1;
- if(q[ii].dian[0].x == x)
- {
- cnt++;
- continue;
- }
- //0表示点在下方
- for(int jj = 1; jj < q[ii].num; jj++)
- {
- int pos = q[ii].dian[jj].x < x? -1:1;
- if(q[ii].dian[jj].x == x)
- {
- cnt++;
- break;
- }
- if(ok * pos == -1)
- {
- cnt++;
- break;
- }
- }
- }
- continue;
- }
- double k = getk(a, b, c, d);
- double bi = b - k*a;
- //枚举第三个多边形
- for(int ii = 0; ii < n; ii++)
- {
- if(ii == i || ii == j)
- continue;
- //0表示点在下方
- if(k*q[ii].dian[0].x + bi - q[ii].dian[0].y == 0)
- {
- cnt++;
- continue;
- }
- int ok = k*q[ii].dian[0].x + bi - q[ii].dian[0].y < 0? -1:1;
- for(int jj = 1; jj < q[ii].num; jj++)
- {
- int pos = k*q[ii].dian[jj].x + bi - q[ii].dian[jj].y < 0? -1:1;
- if(k*q[ii].dian[jj].x + bi - q[ii].dian[jj].y == 0)
- {
- cnt++;
- break;
- }
- if(ok * pos == -1)
- {
- cnt++;
- break;
- }
- }
- }
- _max = max(cnt, _max);
- }
- }
- }
- }
- printf("Case %d: %d\n", count++, _max);
- }
- return 0;
- }
hdu 3952的更多相关文章
- hdu - 3952 Fruit Ninja(简单几何)
思路来自于:http://www.cnblogs.com/wuyiqi/archive/2011/11/06/2238530.html 枚举两个多边形的两个点组成的直线,判断能与几个多边形相交 因为最 ...
- HDU——1130 How Many Trees?
How Many Trees? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
随机推荐
- 让无线网卡同时工作在 AP 和 STA 模式
这个帖子里的方法有点过时了,不推荐继续使用. 有的时候会碰到这么一种情况,带着电脑和手机出去蹭网,无奈只有一个账号,手机上了电脑就没得用了,电脑用了手机就上不了网.如果能用电脑连接 Wifi 然后再开 ...
- sql常识-like
LIKE 操作符用于在 WHERE 子句中搜索列中的指定模式. LIKE 操作符 LIKE 操作符用于在 WHERE 子句中搜索列中的指定模式. SQL LIKE 操作符语法 SELECT colum ...
- 存储过程往拼接的sql语句中传递日期值
存储过程往拼接的sql语句中传递日期值 declare @start datetime declare @end datetime set @start='2014-3-1' set @end='20 ...
- CSS之边框属性
border-style 属性用于设置元素所有边框的样式,或者单独地为各边设置边框样式. border-style:dotted solid double dashed; border-style的属 ...
- Visual Studio Gallery
Web Essentials :对CSS.JavaScript和HTML都提供了很多快捷的功能支持.http://vswebessentials.com/features/general Web Co ...
- 【SQL】关于存储过程调用过程中事务的点点滴滴
1.调用两个存储过程 ---------------------------------------------------------------- -- 表[dbo].[aaa_test]中[id ...
- .NET 的webservice例子
因为项目的需要,可能会经常性的需要调用接口,或者写一些接口.现在提供一些简单的例子给大家参考 写接口: [WebServiceBinding(ConformsTo = WsiProfiles.Basi ...
- iOS夯实:内存管理
iOS夯实:内存管理 文章转自 内存管理 最近的学习计划是将iOS的机制原理好好重新打磨学习一下,总结和加入自己的思考. 有不正确的地方,多多指正. 目录: 基本信息 旧时代的细节 新时代 基本信息 ...
- JqGrid在IE8中表头不能分组的解决办法
修改JqGrid的js脚本: for (d = 0; d < c; d++) { if (b[d] != undefined) { //主要是添加这个判断 if (b[d].startColum ...
- JS面向对象5中写法
//定义Circle类,拥有成员变量r,常量PI和计算面积的成员函数area() //第1种写法 function Circle(r) { this.r = r; } Circle.PI = 3.14 ...