题目链接

题目描述

平面上有 nn 个坐标相异的点,请问当中有多少组非共线的三个点,这三个点的 外心 也在这 nn 个点之中?

 

输入描述

第一行有一个正整数 nn 代表平面上的点数。

接下来有 nn 行,当中的第 ii 行包含两个整数 x_i, y_i,xi​,yi​ 代表第 i 个点的坐标是 (x_i, y_i)(xi​,yi​)。

1<=n<=2000

-10^9<=x,y<=10^9

若 i  != j ,则(xi,yi)!=(xj,yj);

样例输入

5
0 0
-2 0
0 2
-1 1
2 0

样例输出

2

  

    拿到这个题时,想着暴力,但是涉及到四个for,所以超时。比赛时就没搞出来,甚是遗憾。打完后看别人的AC代码,恍然大悟!

    如果一个点到另外三个点的距离相等,那么这三个点肯定不共线,所以这点压根不需要去管了,直接去找一个点a1到另外点的距离,用map记录距离出现次数,如果出现某个距离出现次数K>=3,那么a1是这些点的外心,由于要选组合数,那么进行C K  3就可以了,从出现次数中选择三个就是一组,所以C  K  3。

    另外还有map迭代器的写法,总是忘

#include<cstring>
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
const int maxn = 2e3+;
typedef long long ll;
ll num[maxn];
struct node
{
ll x,y;
}st[maxn];
ll distance(ll x1,ll y1,ll x2, ll y2)
{
return ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
int n ;
cin>>n;
for(int i = ; i< n ; i++)
{
cin>>st[i].x>>st[i].y;
}
ll sum = ;
for(int i = ; i <n ;i ++)
{
map<ll,ll>mm;
for(int j = ; j<n ; j++)
{
if(i!=j)
{
ll s=distance(st[i].x,st[i].y,st[j].x,st[j].y);
// cout<<s<<endl;
mm[s]++;
}
}  
map<ll,ll>::iterator it;  //遍历map写法
for(it = mm.begin();it!=mm.end();it++)
{
if(it->second>=)  
{
ll k = it->second;
// cout<<k<<endl;
sum+=k*(k-)*(k-)/;   //C k 3  
}
}
}
cout<<sum<<endl;
return ;
}

Comet OJ - Contest #15(B: 当我们同心在一起 )的更多相关文章

  1. Comet OJ - Contest #15 题解

    传送门 \(A\) 咕咕 const int N=1005; int a[N],n,T; int main(){ for(scanf("%d",&T);T;--T){ sc ...

  2. Comet OJ Contest #15 D. 双十一特惠(困难版)

    以 $d(x)$ 表示正整数 $x$ 的十进制表示的数位之和.熟知下列关于 $d(x)$ 的结论: $d(x) \equiv x \pmod{9}$.从而对于任意正整数列 $a_1, a_2, \do ...

  3. Comet OJ - Contest #2 简要题解

    Comet OJ - Contest #2 简要题解 cometoj A 模拟,复杂度是对数级的. code B 易知\(p\in[l,r]\),且最终的利润关于\(p\)的表达式为\(\frac{( ...

  4. Comet OJ - Contest #2简要题解

    Comet OJ - Contest #2简要题解 前言: 我没有小裙子,我太菜了. A 因自过去而至的残响起舞 https://www.cometoj.com/contest/37/problem/ ...

  5. Comet OJ - Contest #4--前缀和

    原题:Comet OJ - Contest #4-B https://www.cometoj.com/contest/39/problem/B?problem_id=1577传送门 一开始就想着暴力打 ...

  6. Comet OJ - Contest #11 题解&赛后总结

    Solution of Comet OJ - Contest #11 A.eon -Problem designed by Starria- 在模 10 意义下,答案变为最大数的最低位(即原数数位的最 ...

  7. Comet OJ - Contest #8

    Comet OJ - Contest #8 传送门 A.杀手皇后 签到. Code #include <bits/stdc++.h> using namespace std; typede ...

  8. Comet OJ - Contest #13-C2

    Comet OJ - Contest #13-C2 C2-佛御石之钵 -不碎的意志-」(困难版) 又是一道并查集.最近做过的并查集的题貌似蛮多的. 思路 首先考虑,每次处理矩形只考虑从0变成1的点.这 ...

  9. Comet OJ - Contest #13 「火鼠的皮衣 -不焦躁的内心-」

    来源:Comet OJ - Contest #13 芝士相关: 复平面在信息学奥赛中的应用[雾 其实是道 sb 题??? 发现原式貌似十分可二项式定理,然后发现确实如此 我们把 \(a^i\) 替换成 ...

随机推荐

  1. Centos上安装FastDFS

    更新yum源 cd /etc/yum.repos.d wget http://mirrors.aliyun.com/repo/Centos-7.repo yum update 安装gcc(编译时需要) ...

  2. AngularJS1.X版本基础

    AngularJS  知识点: DataBinding Providers Validators Directives  Controllers Modules Expressions Factori ...

  3. Day6 - E - Brownie Points II POJ - 2464

    Stan and Ollie play the game of Odd Brownie Points. Some brownie points are located in the plane, at ...

  4. 洛谷P1000 超级玛丽游戏(洛谷新手村1-1-1)

    题目背景 本题是洛谷的试机题目,可以帮助了解洛谷的使用. 建议完成本题目后继续尝试P1001.P1008. 题目描述 超级玛丽是一个非常经典的游戏.请你用字符画的形式输出超级玛丽中的一个场景. *** ...

  5. java项目构建工具Maven

    一.java-maven常用命令 mvn archetype:create 创建Maven项目 mvn compile 编译源代码 mvn deploy 发布项目 mvn test-compile 编 ...

  6. Javascript获取当前鼠标在元素内的坐标定位

    代码如下: <!doctype html> <html> <head> <meta charset="utf-8"> <tit ...

  7. 自己写个tween

    public Vector3 begin,end;//起始终止坐标 public float BtoE_time;//用时 float timer,lerp;//计时器和进度值 void Update ...

  8. HttpClient测试

    导入maven依赖 <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson&l ...

  9. Web基础之Dubbo

    Dubbo RPC即Remote Procedure Call,即为远程调用.这和Java的远程代理RMI有点类似,不过RMI只能在Java系统之间进行调用,并且是使用序列化对象的方式进行通信.相比之 ...

  10. pwntool基础和ida常用操作

    pwntools:http://www.91ri.org/14382.html ida:https://www.jianshu.com/p/d425140c6561