Advertisement
Hippskill

Untitled

Jan 19th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.28 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include<stdio.h>
  3. #include<iostream>
  4. #include<vector>
  5. #include<cmath>
  6. #include<algorithm>
  7. #include<memory.h>
  8. #include<map>
  9. #include<set>
  10. #include<queue>
  11. #include<list>
  12. #include<sstream>
  13. #include<cstring>
  14. #include<numeric>
  15. #include<limits.h>
  16. using namespace std;
  17.  
  18.  
  19. struct point {
  20. private: double x, y;
  21. public:
  22.     point() : x(0), y(0) {}
  23.     point(double x, double y) : x(x), y(y) {}
  24.  
  25.     void scan() {
  26.         scanf("%lf%lf", &x, &y);
  27.     }
  28.     point operator+ (const point & P) const {
  29.         return point(x + P.x, y + P.y);
  30.     }
  31.  
  32.     point operator- (const point & P) const {
  33.         return point(x - P.x, y - P.y);
  34.     }
  35.  
  36.     point operator/ (double k) const {
  37.         return point(x / k, y / k);
  38.     }
  39.    
  40.     bool operator== (const point & P) const {
  41.         return x == P.x && y == P.y;
  42.     }
  43.  
  44.     double operator*(const point & P) const {
  45.         return x * P.y - y * P.x;
  46.     }
  47.  
  48.     double dist(const point & P) const {
  49.         point r = P - *this;
  50.         return hypot(r.x, r.y);
  51.     }
  52.  
  53.  
  54. };
  55.  
  56. double triangleArea(point & A, point & B, point & C) {
  57.     return abs((A - B) * (C - B)) * 0.5;
  58. }
  59.  
  60.  
  61. double triangleArea(point & A, point & B, point & C) {
  62.     return abs((A - B) * (C - B)) * 0.5;
  63. }
  64.  
  65. point f[3];
  66. point s[3];
  67.  
  68.  
  69. bool is0() {
  70.     for (int i = 0; i < 3; i++) {
  71.         for (int j = 0; j < 3; j++) {
  72.             for (int z = 0; z < 3; z++) {
  73.                 if (i == j || j == z || z == i) continue;
  74.                 if (f[i] == s[0] && f[j] == s[1] && f[z] == s[2])
  75.                     return true;
  76.             }
  77.         }
  78.     }
  79.     return false;
  80. }
  81.  
  82. bool isEquals() {
  83.     double sidef[3]{ f[0].dist(f[1]), f[1].dist(f[2]), f[0].dist(f[2]) };
  84.     double sides[3]{ s[0].dist(s[1]), s[1].dist(s[1]), s[0].dist(s[2]) };
  85.     for (int i = 0; i < 3; i++) {
  86.         for (int j = 0; j < 3; j++) {
  87.             for (int z = 0; z < 3; z++) {
  88.                 if (i == j || j == z || z == i) continue;
  89.                 if (sidef[i] == sides[0] && sidef[j] == sides[1] && sidef[z] == sides[2])
  90.                     return true;
  91.             }
  92.         }
  93.     }
  94.     return false;
  95. }
  96.  
  97. int main(){
  98.     for (int i = 0; i < 3; i++) {
  99.         f[i].scan();
  100.     }
  101.    
  102.     for (int i = 0; i < 3; i++) {
  103.         s[i].scan();
  104.     }
  105.  
  106.     double fs = triangleArea(f[0], f[1], f[2]);
  107.     double ss = triangleArea(s[0], s[1], s[2]);
  108.  
  109.  
  110.     if (fs != ss) {
  111.         printf("5");
  112.         return 0;
  113.     }
  114.  
  115.     if (is0) {
  116.         printf("0");
  117.         return 0;
  118.     }
  119.  
  120.     if (!isEquals()) {
  121.         printf("4");
  122.         return 0;
  123.     }
  124.  
  125.  
  126.  
  127.    
  128.  
  129.    
  130.  
  131.  
  132.     return 0;
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement