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 ...
随机推荐
- SQL Server2008新特性Filesteam的使用
Filesteam是SQL Server2008的新特性,它结合了SQL Server和NTFS文件系统,为Blob类型的数据提供了比较高效的存储和访问方案.我们最近的一个项目就是采用SQL Serv ...
- C盘空间不足,释放C盘空间
最近电脑总是特别卡,后来发现C盘空间严重不足,只剩下几十兆,以前最严重的时候是剩下0kb可以,怎一个惨字了得... 我所知道的C盘空间不足会导致的几个主要问题有: 1)拷贝大文件会失败.因为拷贝和剪切 ...
- The influence of informal governance mechanisms on knowledge integration
Title:The influence of informal governance mechanisms on knowledge integration within cross-function ...
- (转)Mysql数据库读写分离配置
环境模拟 实现读写分离 减轻数据库的负荷 主服务器 master 10.0.0.12从服务器 slave 10.0.0.66 ------------------------------------- ...
- 关键字 virtual
Virtual是C++ OO机制中很重要的一个关键字.只要是学过C++的人都知道在类Base中加了Virtual关键字的函数就是虚拟函数(例如函数print),于是在Base的派生类Derived中就 ...
- OCI下报出的数据库重账错
[2014-01-09 19:43:45.469220][22347888] Level 0 COCITOOL: Error - OCI_ERROE - errcode[1],errmsg[ORA-0 ...
- 利用HibernateTools从数据库表生成带注解的POJO
在SSH框架中,如果先设计好了数据库,那么下一步就需要从数据库Table生成实体java类和hbm.xml配置文件.在最新的开发框架中,已经支持使用注解,从而避免了繁琐的hbm.xml配置,而且我们可 ...
- tomcat6.0添加ssi(*.shtml)配置
1.去掉tomcat6中conf/web.xml关于ssi的注释 <servlet> <servlet-name>ssi</servlet-name> <se ...
- asp.net 时间比较,常用于在某段时间进行操作
DateTime.Compare(t1,t2)比较两个日期大小,排前面的小,排在后面的大,比如:2011-2-1就小于2012-3-2返回值小于零: t1 小于 t2. 返回值等于零 : t1 等于 ...
- T-SQL数组循环
T-SQL对字符串的处理能力比较弱,比如要循环遍历象1,2,3,4,5这样的字符串,如果用数组的话,遍历很简单,但是T-SQL不支持数组,所以处理下来比较麻烦.下边的函数,实现了象数组一样去处理字符串 ...