Educational Codeforces Round 11 _D
2024-09-29 12:19:22
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 ;
}
一个古老的题
最新文章
- javascript工厂模式和构造函数模式创建对象
- CSS3中的动画效果记录
- Python的平凡之路(21)
- 不管你以后写不写JS,都应该学会这种思考方式
- 判断移动端js代码
- 03-第一个C语言程序的分析
- Javascript基础系列之(五)条件语句(if条件语句)
- python的变量
- [置顶] Android Provision (Setup Wizard)
- JavaScript 对象的几种创建方法
- session 共享
- PB数据管道
- Android Studio环境下搭建ReactNative
- workerman 安装event 扩展
- python学习日记(流程控制习题)
- 如何查看MySQL单个数据库或者表的大小
- z-tree学习笔记
- lsof一些使用
- HDU4409-LCA模拟
- Emulating private methods with closures