A. Number of Triplets
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
You are given n points on a plane. All points are different.

Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC.

The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same.

Input
The first line contains a single integer n (3 ≤ n ≤ 3000) — the number of points.

Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≤ xi, yi ≤ 1000).

It is guaranteed that all given points are different.

Output
Print the single number — the answer to the problem.

Examples
inputCopy
3
1 1
2 2
3 3
outputCopy
1
inputCopy
3
0 0
-1 0
0 1
outputCopy
0

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;struct node{int x,y;friend bool operator < (node a,node b){if(a.x!=b.x)return a.x<b.x;return a.y<b.y;}friend bool operator ==(node a,node b){return a.x==b.x&&a.y==b.y;}
}p[3001];
int n,ans;void judge(int l,int r){while(l<=r){int mid=(l+r)>>1;p[mid]<p[0]?l=mid+1:r=mid-1;}if(p[l]==p[0]||p[r]==p[0])ans++;
}int main(){while(cin>>n){for(int i=1;i<=n;i++)cin>>p[i].x>>p[i].y;sort(p+1,p+1+n);ans=0;for(int i=1;i<n;i++){for(int j=i+1;j<=n;j++){p[0].x=(p[i].x+p[j].x)/2;p[0].y=(p[i].y+p[j].y)/2;if(p[0].x*2==p[i].x+p[j].x&&p[0].y*2==p[i].y+p[j].y){judge(1,n);}}}cout<<ans<<endl;}return 0;
}

Number of Triplets相关推荐

  1. [Swift]LeetCode611. 有效三角形的个数 | Valid Triangle Number

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ ➤微信公众号:山青咏芝(shanqingyongzhi) ➤博客园地址:山青咏芝(https://www.cnblog ...

  2. 语义分割--Mix-and-Match Tuning for Self-Supervised Semantic Segmentation

    Mix-and-Match Tuning for Self-Supervised Semantic Segmentation AAAI Conference on Artificial Intelli ...

  3. Java使用RSA加密解密签名及校验

    RSA加密解密类: import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; i ...

  4. linux下部署tomcat没起成功,linux下部署tomcat 上线jpress博客系统

    tomcat Tomcat服务器是一个免费的开放源代码的Web应用服务器,属于轻量级应用服务器. tomcat有三个端口 开始部署 安装tomcat 第一步:下载tomcat 安装包 tomcat官网 ...

  5. C++ 使用OpenSSL 基于SHA1摘要的RSA签名及验签 与Java平台互通

    文章目录 准备 C++ Java RSASignature.java RSAEncrypt.java Base64.java 准备 配置OpenSSL环境 配置VS2015环境 生成公私秘钥 然后你们 ...

  6. Codeforces Beta Round #57 (Div. 2)E---Enemy is weak(树状数组+离散化)

    The Romans have attacked again. This time they are much more than the Persians but Shapur is ready t ...

  7. Android支付接入(一):支付宝

    转载之前我想深深地感谢屌丝哥 相信相同过App获取利润的都会需要接入计费SDK,下边就跟大家走一遍完整的支付宝SDK接入,支付系列均通过计费Button触发,计费所有代码均放到一个java文件实现,这 ...

  8. UPC-2021个人训练赛第20场-部分题解

    目录 RGB Triplets 题目描述 输入 输出 样例输入 Copy 样例输出 Copy 提示 Select Half 题目描述 输入 输出 样例输入 Copy 样例输出 Copy 提示 心灵的抚 ...

  9. java调用爱贝支付

    目录 1.爱贝支付流程 2.接口说明 2.1下单-获取transid 2.2返回参数及格式 3.代码实现 3.1项目结构 3.2OrderMain 3.3OrderTest 3.4RSA 3.5Bas ...

  10. RSA非对称加密(以Android和java为例)

    一.概念 1.1目的 由于工作中用到了趟过了许多的坑所以深有体会,所以想写个笔记怕以后忘记了,好到时候回来看看. 首先是一定要知道最基础的概念,一定要知道最基础的概念,一定要知道最基础的概念,以免被误 ...

最新文章

  1. Visual Studio Code Go 插件文档翻译
  2. 0x55. 动态规划 - 环形与后效性处理(例题详解 × 6)
  3. 建立自己的git账户并保存资料的重要性
  4. PHP会话管理——Session和Cookie
  5. POJ 2263 Heavy Cargo 多种解法
  6. 暴力 Codeforces Round #183 (Div. 2) A. Pythagorean Theorem II
  7. Android开发笔记(一百一十九)工具栏ToolBar
  8. 计算机注销之后一直黑屏,win7系统注销出现黑屏怎么办_win7系统注销出现黑屏的修复办法...
  9. web网站页面实现设计代码
  10. Chrome 启动页面被114篡改的修复
  11. 如何申请电子邮箱,怎样注册163邮箱
  12. Origin坐标轴上的连字符修改为负号
  13. 2020奶茶行业研究报告
  14. matlab复数方程的根,matlab解超越方程的复数根
  15. C语言练习题:厘米换算英尺英寸
  16. 防火墙控制Docker端口开放与关闭
  17. 泛微e-office怎么样?
  18. 根据前台设计数据库--首页篇
  19. swagger2注解详细说明
  20. 不同业务场景Cas客户端(Java业务系统)接入

热门文章

  1. 一群猴子要选新猴王。新猴王的选择方法是:让N只候选猴子围成一圈,从某位置起顺序编号为1~N号。从第1号开始报数,每轮从1报到3,凡报到3的猴子即退出圈子,接着又从紧邻的下一只猴子开始同样的报数。
  2. 机器朗读发音电脑说话
  3. 前端开发中spa的优缺点_使用单Spa开发和部署微前端
  4. js案例一 :方块拖动效果
  5. js的alert弹框中怎么写html,JavaScript实现alert弹框效果
  6. 微信备份服务器,数码早知道 篇五:终于支持微信备份了!群晖Drive X 内测信息流出汇总!...
  7. python 实验八 函数 (上)
  8. 基于PHP课程网站设计开题报告,在线课程网站设计开题报告
  9. Linux磁盘空间说明
  10. 【备忘】【No5】微信公众平台开发入门到实战开发视频教程(Java+PHP)