麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發(fā)設計 > 正文

LEETCODE--Number of Boomerangs

2019-11-11 05:44:21
字體:
供稿:網(wǎng)友

Given n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters). Find the number of boomerangs. You may assume that n will be at most 500 and coordinates of points are all in the range [-10000, 10000] (inclusive). Example: Input: [[0,0],[1,0],[2,0]]

Output: 2

Explanation: The two boomerangs are [[1,0],[0,0],[2,0]] and [[1,0],[2,0],[0,0]]

熟悉使用map

class Solution {public: int numberOfBoomerangs(vector<pair<int, int>>& points) { int num = 0; for(int i = 0; i < points.size(); i++){ map<long,int> group; for(int j = 0; j < points.size(); j++){ if(i == j) continue; int distance_x = points[j].first - points[i].first; int distance_y = points[j].second - points[i].second; int key = distance_x * distance_x + distance_y * distance_y; ++group[key]; } for(auto& p : group){ int val = p.second; if(val > 1) num += val * (val - 1); } } return num; }};
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 免费中文视频 | 久久久久久麻豆 | 久久艳片 | 国产精品99久久久久久久女警 | 欧美日韩亚洲成人 | av电影直播 | chinesexxxx极品少妇 | 国产精品久久久久久久四虎电影 | 黄色一级毛片免费看 | 欧美淫交 | 免费毛片a线观看 | 国产一级淫片在线观看 | 一级空姐毛片 | 久久九九热re6这里有精品 | 亚洲精品v天堂中文字幕 | 欧美色视频免费 | 亚州视频在线 | 深夜激情视频 | 欧美毛片 | 在线观看一二区 | 亚洲一区二区在线视频 | 中文字幕亚洲一区二区三区 | 操碰视频在线观看 | 曰韩一级片 | 亚洲自拍第一 | 欧美日韩在线视频一区 | 欧美日韩大片在线观看 | 欧美成人毛片 | 欧美综合成人 | 在线a亚洲视频播放在线观看 | 日韩av电影在线观看 | 一级做a爰片性色毛片2021 | 成人午夜淫片a | 在线日韩av电影 | 国产成人免费精品 | 欧美三级欧美成人高清www | 亚洲欧美aⅴ | 国产亚洲欧美日韩在线观看不卡 | 99国产精成人午夜视频一区二区 | 亚洲免费观看视频 | 久久精品一区二区三区四区五区 |