链接

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

这题本来用以斜率和长度为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. 在ecshop顶部会员信息提示区显示会员等级

    会员登陆后,在顶部会员信息提示区显示会员等级会员登陆后会在顶部出现这样的提示:您好,test2, 欢迎您回来 ! 进入用户中心 |退出现在设想在会员名后面加上“会员等级”效果如下:您好,test2,  ...

  2. 计算机学院大学生程序设计竞赛(2015’12)Polygon

    Polygon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  3. Python相对路径转绝对路径,绝对路径转相对路径

    1.绝对路径转相对路径 print os.path.relpath("d:/MyProj/MyFile.txt") #..\MyProj\MyFile.txt 是根据当前路径的相对 ...

  4. 反射获取类中的属性和set属性

    package framework.base; import java.beans.IntrospectionException; import java.beans.PropertyDescript ...

  5. nylg 640 Geometric Sum

    Geometric Sum 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 Compute (a + a^2 + … + a^n) mod m.(a+a2+…an)m ...

  6. Java爬虫工程师技能列表

    以下仅仅是自己一些粗浅认识.欢迎补充指正.欢迎进群交流! 掌握一半便能够熟练的开发爬虫玩了.自己正在努力中... 一.技能列表 1.掌握java.尤其编程网络部分:李刚的java基础至少看了三遍以上: ...

  7. 关于stack around the variable “” was corrupted问题

    很坑爹的问题,异常信息表示我的缓冲区如数组越界了,可是老子明明没有越界. 解决方法:关闭vs检查代码是否越界的功能: 属性->c/c++->代码生成->基本运行时检查,改为默认值

  8. CANopen笔记2

    PDO 过程数据对象用于在节点之间传送过程数据,如I/O模块I/O状态读取和设定,模拟量采集和模拟量输出等等,协议考虑从机硬件限制最多支持4组PDO,每组包含一个RPDO和一个TPDO.The Gol ...

  9. Creating, Stopping, Re-Starting and Deleting a Timer in Oracle Forms

    I have written many posts previously on Timers in Oracle Forms like how to change images randomly wi ...

  10. Know How And When To Use System.Message_Level To Control Messages In Oracle Forms

    SYSTEM.MESSAGE_LEVEL is used to control the messages that end users see when they use the Oracle For ...