因为一个小错 不过  好不爽........

  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. struct Node
  5. {
  6. int x, y;
  7. };
  8. class shap
  9. {
  10. public:
  11. int num;
  12. Node dian[22];
  13. } q[22];
  14. double getk(int x1, int y1, int x2, int y2)
  15. {
  16. return (double)(y1-y2)/(double)(x1-x2);
  17. }
  18. double esp = 1e-7;
  19. int main(void)
  20. {
  21. // freopen("1.txt", "r", stdin);
  22. int kase;
  23. cin>>kase;
  24. int n;
  25. int count = 1;
  26. while(kase-- && cin>>n)
  27. {
  28. int m;
  29. for(int i = 0; i < n; i++)
  30. {
  31. cin>>m;
  32. q[i].num = m;
  33. for(int j = 0; j < m; j++)
  34. cin>>q[i].dian[j].x>>q[i].dian[j].y;
  35. }
  36. if(n <= 2)
  37. {
  38. printf("Case %d: %d\n", count++, n);
  39. continue;
  40. }
  41. int _max = 2;
  42. for(int i = 0; i < n; i++)
  43. {
  44. for(int j = i+1; j < n; j++)
  45. {
  46. for(int k = 0; k < q[i].num; k++)
  47. {
  48. for(int g = 0; g < q[j].num; g++)
  49. {
  50. int a = q[i].dian[k].x;
  51. int b = q[i].dian[k].y;
  52.  
  53. int c = q[j].dian[g].x;
  54. int d = q[j].dian[g].y;
  55.  
  56. int cnt = 2;
  57. if(a == c)
  58. {
  59. for(int ii = 0; ii < n; ii++)
  60. {
  61. if(ii == i || ii == j)
  62. continue;
  63. int x = a;
  64. int ok = q[ii].dian[0].x < x? -1:1;
  65.  
  66. if(q[ii].dian[0].x == x)
  67. {
  68. cnt++;
  69. continue;
  70. }
  71. //0表示点在下方
  72. for(int jj = 1; jj < q[ii].num; jj++)
  73. {
  74. int pos = q[ii].dian[jj].x < x? -1:1;
  75. if(q[ii].dian[jj].x == x)
  76. {
  77. cnt++;
  78. break;
  79. }
  80. if(ok * pos == -1)
  81. {
  82. cnt++;
  83. break;
  84. }
  85. }
  86. }
  87. continue;
  88. }
  89. double k = getk(a, b, c, d);
  90. double bi = b - k*a;
  91.  
  92. //枚举第三个多边形
  93. for(int ii = 0; ii < n; ii++)
  94. {
  95. if(ii == i || ii == j)
  96. continue;
  97. //0表示点在下方
  98. if(k*q[ii].dian[0].x + bi - q[ii].dian[0].y == 0)
  99. {
  100. cnt++;
  101. continue;
  102. }
  103. int ok = k*q[ii].dian[0].x + bi - q[ii].dian[0].y < 0? -1:1;
  104. for(int jj = 1; jj < q[ii].num; jj++)
  105. {
  106. int pos = k*q[ii].dian[jj].x + bi - q[ii].dian[jj].y < 0? -1:1;
  107. if(k*q[ii].dian[jj].x + bi - q[ii].dian[jj].y == 0)
  108. {
  109. cnt++;
  110. break;
  111. }
  112. if(ok * pos == -1)
  113. {
  114. cnt++;
  115. break;
  116. }
  117. }
  118. }
  119. _max = max(cnt, _max);
  120. }
  121. }
  122. }
  123. }
  124. printf("Case %d: %d\n", count++, _max);
  125. }
  126.  
  127. return 0;
  128. }

hdu 3952的更多相关文章

  1. hdu - 3952 Fruit Ninja(简单几何)

    思路来自于:http://www.cnblogs.com/wuyiqi/archive/2011/11/06/2238530.html 枚举两个多边形的两个点组成的直线,判断能与几个多边形相交 因为最 ...

  2. HDU——1130 How Many Trees?

    How Many Trees? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  3. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  4. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  5. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  6. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  7. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  8. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  9. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

随机推荐

  1. 让无线网卡同时工作在 AP 和 STA 模式

    这个帖子里的方法有点过时了,不推荐继续使用. 有的时候会碰到这么一种情况,带着电脑和手机出去蹭网,无奈只有一个账号,手机上了电脑就没得用了,电脑用了手机就上不了网.如果能用电脑连接 Wifi 然后再开 ...

  2. sql常识-like

    LIKE 操作符用于在 WHERE 子句中搜索列中的指定模式. LIKE 操作符 LIKE 操作符用于在 WHERE 子句中搜索列中的指定模式. SQL LIKE 操作符语法 SELECT colum ...

  3. 存储过程往拼接的sql语句中传递日期值

    存储过程往拼接的sql语句中传递日期值 declare @start datetime declare @end datetime set @start='2014-3-1' set @end='20 ...

  4. CSS之边框属性

    border-style 属性用于设置元素所有边框的样式,或者单独地为各边设置边框样式. border-style:dotted solid double dashed; border-style的属 ...

  5. Visual Studio Gallery

    Web Essentials :对CSS.JavaScript和HTML都提供了很多快捷的功能支持.http://vswebessentials.com/features/general Web Co ...

  6. 【SQL】关于存储过程调用过程中事务的点点滴滴

    1.调用两个存储过程 ---------------------------------------------------------------- -- 表[dbo].[aaa_test]中[id ...

  7. .NET 的webservice例子

    因为项目的需要,可能会经常性的需要调用接口,或者写一些接口.现在提供一些简单的例子给大家参考 写接口: [WebServiceBinding(ConformsTo = WsiProfiles.Basi ...

  8. iOS夯实:内存管理

    iOS夯实:内存管理 文章转自 内存管理 最近的学习计划是将iOS的机制原理好好重新打磨学习一下,总结和加入自己的思考. 有不正确的地方,多多指正. 目录: 基本信息 旧时代的细节 新时代 基本信息 ...

  9. JqGrid在IE8中表头不能分组的解决办法

    修改JqGrid的js脚本: for (d = 0; d < c; d++) { if (b[d] != undefined) { //主要是添加这个判断 if (b[d].startColum ...

  10. JS面向对象5中写法

    //定义Circle类,拥有成员变量r,常量PI和计算面积的成员函数area() //第1种写法 function Circle(r) { this.r = r; } Circle.PI = 3.14 ...