链接

越来越感觉到了数学的重要性!。。

这题本来用以斜率和长度为key值进行hash不过感觉很麻烦还TLE了。。

最后知道中点一样的话就可以组成平行四边形,初中数学就可以了。。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define N 1010
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct point
{
int x,y;
} p[N],o[N*N]; bool cmp(point a,point b)
{
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
int main()
{
int t,n,i,j;
cin>>t;
while(t--)
{
scanf("%d",&n);
for(i = ; i <= n ; i++)
{
scanf("%d%d",&p[i].x,&p[i].y);
}
int g = ;
for(i = ; i<= n ; i++)
{
for(j = i+ ; j <= n ;j++)
{
o[++g].x = (p[i].x+p[j].x);
o[g].y = (p[i].y+p[j].y);
// cout<<o[g].y<<endl;
}
}
LL ans = ;
sort(o+,o+g+,cmp);
int e = ;
for(i = ; i <= g ;i++)
{
if(o[i].x-o[i-].x==&&o[i].y-o[i-].y==)
{
e++;
// cout<<o[i].x<<" ,"<<o[i-1].x<<" "<<o[i].y<<" "<<o[i-1].y<<endl;
}
else
{
ans+=(LL)(e-)*e/;
e = ;
}
}
ans+=(LL)(e-)*e/;
cout<<ans<<endl;
}
return ;
}

poj1971Parallelogram Counting的更多相关文章

  1. 萌新笔记——Cardinality Estimation算法学习(二)(Linear Counting算法、最大似然估计(MLE))

    在上篇,我了解了基数的基本概念,现在进入Linear Counting算法的学习. 理解颇浅,还请大神指点! http://blog.codinglabs.org/articles/algorithm ...

  2. POJ_2386 Lake Counting (dfs 错了一个负号找了一上午)

    来之不易的2017第一发ac http://poj.org/problem?id=2386 Lake Counting Time Limit: 1000MS   Memory Limit: 65536 ...

  3. ZOJ3944 People Counting ZOJ3939 The Lucky Week (模拟)

    ZOJ3944 People Counting ZOJ3939 The Lucky Week 1.PeopleConting 题意:照片上有很多个人,用矩阵里的字符表示.一个人如下: .O. /|\ ...

  4. find out the neighbouring max D_value by counting sort in stack

    #include <stdio.h> #include <malloc.h> #define MAX_STACK 10 ; // define the node of stac ...

  5. 1004. Counting Leaves (30)

    1004. Counting Leaves (30)   A family hierarchy is usually presented by a pedigree tree. Your job is ...

  6. 6.Counting Point Mutations

    Problem Figure 2. The Hamming distance between these two strings is 7. Mismatched symbols are colore ...

  7. 1.Counting DNA Nucleotides

    Problem A string is simply an ordered collection of symbols selected from some alphabet and formed i ...

  8. uva 11401 Triangle Counting

    // uva 11401 Triangle Counting // // 题目大意: // // 求n范围内,任意选三个不同的数,能组成三角形的个数 // // 解题方法: // // 我们设三角巷的 ...

  9. JSONKit does not support Objective-C Automatic Reference Counting(ARC) / ARC forbids Objective-C objects in struct

    当我们在使用JSONKit处理数据时,直接将文件拉进项目往往会报这两个错“JSONKit   does not support Objective-C Automatic Reference Coun ...

随机推荐

  1. iOS 第一次安装应用,拒绝相机调用,页面卡死的解决方案

    void (^allowBlock)() = ^{ UIImagePickerController *imagePicker = [[UIImagePickerController alloc] in ...

  2. Bellman-Ford 算法及其优化

    Bellman-Ford 算法及其优化 转自:http://hi.baidu.com/jzlikewei/blog/item/94db7950f96f995a1038c2cd.html Bellman ...

  3. Java学习之路(一)

    小知识: 1:1973年 贝尔实验室 => c语言 2:sun 的意思是:斯坦福大学校园网 3::1994  oak 被命名为Java JDK(Java开发工具包) 1:下载JDK 2:安装JD ...

  4. UVa(1658),Admiral,海军上将,拆点,MCMF

    题目链接:https://uva.onlinejudge.org/external/16/1658.pdf 题意:求1到N的两条路(不能相交),距离和最小. 分析: 第一次做拆点,有点意思.刚开始一直 ...

  5. C#之猴子吃桃儿问题的解法——猴子吐桃儿

    猴子第一天摘了许多个桃子,先吃了所有桃子的一半,后又吃了一个:第二天又吃了剩下桃子的一半,后又吃了一个……第十天,剩1个桃子.问:猴子第一天摘了多少个桃子? 首先对“猴子吃桃”的过程进行正向推导,设: ...

  6. 怎样解决:未找到路径“……”的控制器或该控制器未实现 IController?

    就是要加上new{area=""},比如下面的: @{Html.RenderAction("Cartsummary","ShoppingCart&qu ...

  7. js的选择星级评分插件

    需要引入jquery和raty的js,并且低版本的jquery可能会出现样式问题,或者点击没反应,可换高版本试试 raty文档及下载: http://www.wbotelhos.com/raty/ 把 ...

  8. 邮箱性质--全选单选的操作和传值 用属性的name传值

    封装类 using System; using System.Collections.Generic; using System.Web; /// <summary> /// Ha 的摘要 ...

  9. [kipmi0]进程导致系统负载高

    最近一个用户这边服务器运行四五天就会出现服务器负载很高的情况,原本正常是0.3~0.5左右  不正常的时候会达到3,重启机器就正常,开始以为是程序问题,后来在观察的时候把程序给杀掉了 然后重启,结果负 ...

  10. 腾讯微博模拟登陆+数据抓取(java实现)

    不多说,贴出相关代码. 参数实体: package token.def; import java.io.Serializable; import java.util.Properties; publi ...