http://codeforces.com/contest/660/problem/D

这个题据说是很老的题了 然而我现在才知道做法

用map跑了1953ms;

题目大意 给你n个点的坐标 求这些点能组成多少个位置不同的四边形

我们统计两个点之间的中点坐标  假如有n对点的中点重合 那么我们就知道这里面有(n-1)*n/2个平行四边形

就这样搞喽。

PS:说实话typedef pair<double,double> pdd; 这语句让我想到了骚猪PDD 笑死了。

#include<cstdio>
#include<map>
//#include<bits/stdc++.h>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<climits>
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<double,double> pdd;
typedef __int64 int64;
const ll mood=1e9+;
const int64 Mod=;
const double eps=1e-;
const int N=2e7+;
const int MAXN=;
inline void rl(ll&num){
num=;ll f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<='')num=num*+ch-'',ch=getchar();
num*=f;
}
inline void ri(int &num){
num=;int f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<='')num=num*+ch-'',ch=getchar();
num*=f;
}
double a[MAXN],b[MAXN];
int main()
{
int n;
map<pdd,int>mp;
ri(n);
for(int i=;i<n;i++)
{
scanf("%lf%lf",&a[i],&b[i]);
}
pdd x;
for(int i=;i<n;i++)
{
for(int j=i+;j<n;j++)
{
x.first=(a[i]+a[j])/;
x.second=(b[i]+b[j])/;
mp[x]++;
}
}
ll ans=;
map<pdd,int>::iterator it;
for(it=mp.begin();it!=mp.end();++it)
{
int tem=it->second;
pdd t=it->first;
ans+=(tem-)*tem/;
}
cout<<ans<<endl;
return ;
}

一个古老的题

最新文章

  1. javascript工厂模式和构造函数模式创建对象
  2. CSS3中的动画效果记录
  3. Python的平凡之路(21)
  4. 不管你以后写不写JS,都应该学会这种思考方式
  5. 判断移动端js代码
  6. 03-第一个C语言程序的分析
  7. Javascript基础系列之(五)条件语句(if条件语句)
  8. python的变量
  9. [置顶] Android Provision (Setup Wizard)
  10. JavaScript 对象的几种创建方法
  11. session 共享
  12. PB数据管道
  13. Android Studio环境下搭建ReactNative
  14. workerman 安装event 扩展
  15. python学习日记(流程控制习题)
  16. 如何查看MySQL单个数据库或者表的大小
  17. z-tree学习笔记
  18. lsof一些使用
  19. HDU4409-LCA模拟
  20. Emulating private methods with closures

热门文章

  1. 微信小程序开发之页面wxml里面实现循环 wx:for
  2. EasyUI 启用行内编辑
  3. UVa 12333 Revenge of Fibonacci (字典树+大数)
  4. android摄像头获取图像——第二弹
  5. hdu2147(yy)
  6. 反射记录点滴——Field
  7. PostgreSQL-11-WITH语句
  8. java快速排序代码
  9. 缺少mscvr100.dll
  10. [洛谷P2186] 小Z的栈函数