Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. class Point{
  7. public:
  8. int x;
  9. int y;
  10. Point(int x, int y){
  11. this->x=x;
  12. this->y=y;
  13. }
  14. int get_x(){
  15. return x;
  16. }
  17. int get_y(){
  18. return y;
  19. }
  20. };
  21.  
  22. int simetricx(int x1, int x2 ){
  23. int x3=2*x2-x1;
  24.  
  25. return x3;
  26. }
  27. int simetricy(int y1, int y2){
  28. int y3=2*y2-y1;
  29. return y3;
  30. }
  31.  
  32. int main(){
  33.  
  34. int k;
  35. cin>>k;
  36. for(int j=0;j<k;j++){
  37. int n;
  38. cin>>n;
  39. vector<Point>coord;
  40. if(n%2!=0) cout<<'0'<<"\n";
  41. else{
  42. int sumax=0, sumay=0;
  43. for(int i=0;i<n;i++){
  44. int x,y;
  45. cin>>x>>y;
  46. Point punct(x,y);
  47. coord.push_back(punct);
  48. sumax=sumax+x;
  49. sumay=sumay+y;
  50. }
  51. int p=0;
  52. int Gx,Gy;
  53.  
  54. if(sumax==0)Gx=0;
  55. else Gx=sumax/n;
  56.  
  57. if(sumay==0)Gy=0;
  58. else Gy=sumay/n;
  59.  
  60. if(Gx==Gy){
  61. cout<<'1'<<' ';
  62. float gx=Gx, gy=Gy;
  63. printf("%.4f %.4f\n",gx,gy);
  64.  
  65. }
  66. else {
  67. for(int i=0;i<n-1;i++){
  68. int Ax,Ay;
  69. Ax=simetricx(coord[i].get_x(),Gx);
  70. Ay=simetricx(coord[i].get_y(),Gy);
  71.  
  72. for(int b=i;b<n;b++)
  73. if(Ax==coord[b].get_x()&&Ay==coord[b].get_y()){
  74. p++;
  75. cout<<p<<' ';
  76. float gx=Gx;
  77. float gy=Gy;
  78. printf("%.4f %.4f\n",gx,gy);
  79.  
  80. }
  81.  
  82. }
  83. if(p==0) cout<<'0'<<"\n";
  84. }
  85.  
  86. }
  87.  
  88. coord.clear();
  89. }
  90. return 0;
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement