zoukankan      html  css  js  c++  java
  • Leetcode-5051 Valid Boomerang(有效的回旋镖)

     1 class Solution
     2 {
     3     public:
     4         bool isBoomerang(vector<vector<int>>& points)
     5         {
     6             if(points[0][0] == points[1][0] && points[0][1] == points[1][1]
     7               || points[1][0] == points[2][0] && points[1][1] == points[2][1]
     8               ||points[0][0] == points[2][0] && points[0][1] == points[2][1]
     9               || points[0][0] == points[1][0] && points[1][0] == points[2][0]
    10               || points[0][1] == points[1][1] && points[1][1] == points[2][1])
    11             return false;
    12             double a = (double)(points[0][0] - points[1][0]) / (points[0][1] - points[1][1]);
    13             double b = (double)(points[1][0] - points[2][0]) / (points[1][1] - points[2][1]);
    14             double c = (double)(points[0][0] - points[2][0]) / (points[0][1] - points[2][1]);
    15 
    16             if(abs(a-b)<1e-3 && abs(a-c)<1e-3)
    17                 return false;
    18             return true;
    19         }
    20 };

    也不知道在写什么,加特判加一堆,还好过了

  • 相关阅读:
    信息探测
    Hdu 1262 寻找素数对
    Hdu 1263 水果
    Hdu 1261字串数
    Hdu 1253 胜利大逃亡
    Hdu 1237简单计算器
    Hdu 1235 统计同成绩学生人数
    Hdu 1236 排名
    Hdu 1233 还是畅通工程
    Hdu 1234 开门人和关门人
  • 原文地址:https://www.cnblogs.com/Asurudo/p/10812273.html
Copyright © 2011-2022 走看看