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]]

class Solution(object):
def numberOfBoomerangs(self, points):
"""
:type points: List[List[int]]
:rtype: int
"""
ans=0
for i in points:
a={}
for j in points:
c=(i[0]-j[0])**2+(i[1]-j[1])**2
if c not in a:
a[c]=1
else:
ans+=a[c]
a[c]+=1
return ans*2

  

最新文章

  1. Acadia Lab 6 轮盘游戏机
  2. Loadrunner上传与下载文件脚本
  3. C/C++ http协议加载sessionID
  4. MyScript 手写识别数学公式、图形 自动计算
  5. java笔记--使用事件分配线程更新Swing控件
  6. Kalendar server Beijing Tiandiyuandian Technology Limited 果然是木马
  7. Centos tar命令
  8. Visual Studio 2012 update3 安装后的问题及解决
  9. PHP中超全局变量$GLOBALS和global的区别
  10. [转载]Python实现浏览器自动化操作
  11. 十、VueJs 填坑日记之在项目中使用Amaze UI
  12. C++学习-9
  13. Charles 使用
  14. ionic3 表单输入元素input的三种事件
  15. 使用现有的appid和appsecret无法打开二维码
  16. 自动化测试-1.selenium简介
  17. CASE WHEN 及 SELECT CASE WHEN的用法(写了一坨烂代码发现两条sql就行了, 哎)
  18. VULKAN学习笔记-inter教学四篇
  19. PHP采集库-Snoopy.class.php
  20. VHF、UHF的频率范围

热门文章

  1. 读取图片列表——CNN输入
  2. vsftpd更新和修改版本号教程
  3. 使用Spring-data-jpa(1)(三十)
  4. jeasyUI DataGrid 根据屏幕宽度自适应, 改变右侧滚动条Size
  5. 逆袭之旅DAY16.东软实训.Oracle.索引
  6. learning ddr mode reigsters
  7. Java单例模式《二》懒汉式
  8. jsp标签之jsp:setProperty用法
  9. oracle查看编码以及修改编码
  10. idea查看jar包是否存在