Advertisement
Hippskill

Untitled

Jan 19th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.36 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.  
  62. point f[3];
  63. point s[3];
  64.  
  65.  
  66. bool is0() {
  67.     for (int i = 0; i < 3; i++) {
  68.         for (int j = 0; j < 3; j++) {
  69.             for (int z = 0; z < 3; z++) {
  70.                 if (i == j || j == z || z == i) continue;
  71.                 if (f[i] == s[0] && f[j] == s[1] && f[z] == s[2])
  72.                     return true;
  73.             }
  74.         }
  75.     }
  76.     return false;
  77. }
  78.  
  79. bool isEquals() {
  80.     double sidef[3]{ f[0].dist(f[1]), f[1].dist(f[2]), f[0].dist(f[2]) };
  81.     double sides[3]{ s[0].dist(s[1]), s[1].dist(s[1]), s[0].dist(s[2]) };
  82.     for (int i = 0; i < 3; i++) {
  83.         for (int j = 0; j < 3; j++) {
  84.             for (int z = 0; z < 3; z++) {
  85.                 if (i == j || j == z || z == i) continue;
  86.                 if (sidef[i] == sides[0] && sidef[j] == sides[1] && sidef[z] == sides[2])
  87.                     return true;
  88.             }
  89.         }
  90.     }
  91.     return false;
  92. }
  93.  
  94. int main(){
  95.     for (int i = 0; i < 3; i++) {
  96.         f[i].scan();
  97.     }
  98.    
  99.     for (int i = 0; i < 3; i++) {
  100.         s[i].scan();
  101.     }
  102.  
  103.     double fs = triangleArea(f[0], f[1], f[2]);
  104.     double ss = triangleArea(s[0], s[1], s[2]);
  105.  
  106.  
  107.     if (fs != ss) {
  108.         printf("5");
  109.         return 0;
  110.     }
  111.  
  112.     if (is0) {
  113.         printf("0");
  114.         return 0;
  115.     }
  116.  
  117.     if (!isEquals()) {
  118.         printf("4");
  119.         return 0;
  120.     }
  121.  
  122.     double len = f[0].dist(s[0]);
  123.     bool p = false;
  124.  
  125.     for (int i = 1; i < 3; i++) {
  126.         if (f[i].dist(s[i]) != len) {
  127.             p = false;
  128.         }
  129.     }
  130.  
  131.     if (p) {
  132.         printf("1");
  133.         return 0;
  134.     }
  135.  
  136.  
  137.  
  138.     return 0;
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement