fork download
  1. #include <queue>
  2. #include <stack>
  3. #include <math.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <iostream>
  7. #include <limits.h>
  8. #include <string.h>
  9. #include <string>
  10. #include <algorithm>
  11. #define pi acos(-1.0)
  12. using namespace std;
  13. const int MAX = 120000;
  14. const double eps = 1e-6;
  15. bool dy(double x,double y) { return x > y + eps;} // x > y
  16. bool xy(double x,double y) { return x < y - eps;} // x < y
  17. bool dyd(double x,double y) { return x > y - eps;} // x >= y
  18. bool xyd(double x,double y) { return x < y + eps;} // x <= y
  19. bool dd(double x,double y) { return fabs( x - y ) < eps;} // x == y
  20. struct point{ double x,y; };
  21. point c[MAX];
  22.  
  23. double degree(point a,point b,double c)
  24. {
  25.  
  26.  
  27.  
  28. if(a.x==b.x && a.y==b.y)return 0.00;
  29. /*d1=b.x-a.x;
  30.   d2=b.y-a.y;
  31.   bot=sqrt (d1*d1 + d2*d2);
  32.   cout<<(d2/bot)<<" "<<d2<<" "<<d1<<"\n";
  33.   return (180*(acos(d2/bot)/pi));*/
  34.  
  35. point A,B;
  36. A.X=b.X-a.X;
  37. A.Y=b.Y-a.Y;
  38. B.X=c-a.X;
  39. B.Y=c-a.Y;
  40. int top;
  41. top=(A.X*B.X)+(A.Y*B.Y);
  42. double bot=sqrt((A.X*A.X)+(A.Y*A.Y))*sqrt((B.X*B.X)+(B.Y*B.Y));
  43. cout<<top*1.0/bot<<"\n";
  44. return 180*acos(top*1.0/bot)/acos(-1);
  45.  
  46.  
  47. }
  48.  
  49.  
  50.  
  51. double crossProduct(point a,point b,point c)//向量 ac 在 ab 的方向
  52. {
  53. return (c.x - a.x)*(b.y - a.y) - (b.x - a.x)*(c.y - a.y);
  54. }
  55. bool cmp(point a,point b) // 排序
  56. {
  57. double len = crossProduct(c[0],a,b);
  58. if( dd(len,0.0) )
  59. return xy(disp2p(c[0],a),disp2p(c[0],b));
  60. return xy(len,0.0);
  61. }
  62. int stk[MAX];
  63. int top;
  64. void Graham(int n)
  65. {
  66. int tmp = 0;
  67. for(int i=1; i<n; i++)
  68. if( xy(c[i].x,c[tmp].x) || dd(c[i].x,c[tmp].x) && xy(c[i].y,c[tmp].y) )
  69. tmp = i;
  70. swap(c[0],c[tmp]);
  71. sort(c+1,c+n,cmp);
  72. stk[0] = 0; stk[1] = 1;
  73. top = 1;
  74. for(int i=2; i<n; i++)
  75. {
  76. while( xyd( crossProduct(c[stk[top]],c[stk[top-1]],c[i]), 0.0 ) && top >= 1 )
  77. top--;
  78. stk[++top] = i;
  79. }
  80. double sum = 0.0;
  81.  
  82.  
  83. for( int i=top; i>0; i--)
  84. printf("(%.1lf,%.1lf)\n",c[stk[i]].x,c[stk[i]].y);
  85.  
  86.  
  87.  
  88. double ans=360.0;
  89. int cs=0;
  90. for(int i=0;i<top-1;i++)
  91. ans=min(ans,degree(c[stk[i]],c[stk[i+1]],0.00));
  92. printf("Case %d: %0.7lf\n",cs++,ans);
  93. }
  94. int main()
  95. {
  96. int n;
  97. int ncases = 1;
  98. while( ~scanf("%d",&n) && n )
  99. {
  100. for(int i=0; i<n; i++)
  101. scanf("%lf%lf",&c[i].x,&c[i].y);
  102. //printf("Region #%d:/n",ncases++);
  103. Graham(n);
  104. }
  105. return 0;
  106. }
  107.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin

1

4 4

4

0 0

10 0

10 10

2 1
0
compilation info
prog.cpp: In function ‘double degree(point, point, double)’:
prog.cpp:36: error: ‘struct point’ has no member named ‘X’
prog.cpp:36: error: ‘struct point’ has no member named ‘X’
prog.cpp:36: error: ‘struct point’ has no member named ‘X’
prog.cpp:37: error: ‘struct point’ has no member named ‘Y’
prog.cpp:37: error: ‘struct point’ has no member named ‘Y’
prog.cpp:37: error: ‘struct point’ has no member named ‘Y’
prog.cpp:38: error: ‘struct point’ has no member named ‘X’
prog.cpp:38: error: ‘struct point’ has no member named ‘X’
prog.cpp:39: error: ‘struct point’ has no member named ‘Y’
prog.cpp:39: error: ‘struct point’ has no member named ‘Y’
prog.cpp:41: error: ‘struct point’ has no member named ‘X’
prog.cpp:41: error: ‘struct point’ has no member named ‘X’
prog.cpp:41: error: ‘struct point’ has no member named ‘Y’
prog.cpp:41: error: ‘struct point’ has no member named ‘Y’
prog.cpp:42: error: ‘struct point’ has no member named ‘X’
prog.cpp:42: error: ‘struct point’ has no member named ‘X’
prog.cpp:42: error: ‘struct point’ has no member named ‘Y’
prog.cpp:42: error: ‘struct point’ has no member named ‘Y’
prog.cpp:42: error: ‘struct point’ has no member named ‘X’
prog.cpp:42: error: ‘struct point’ has no member named ‘X’
prog.cpp:42: error: ‘struct point’ has no member named ‘Y’
prog.cpp:42: error: ‘struct point’ has no member named ‘Y’
prog.cpp: In function ‘bool cmp(point, point)’:
prog.cpp:59: error: ‘disp2p’ was not declared in this scope
prog.cpp: In function ‘void Graham(int)’:
prog.cpp:68: warning: suggest parentheses around && within ||
prog.cpp:80: warning: unused variable ‘sum’
prog.cpp: In function ‘int main()’:
prog.cpp:97: warning: unused variable ‘ncases’
prog.cpp:101: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout
Standard output is empty