http://www.lightoj.com/volume_showproblem.php?problem=1058

题意:给你顶点,问能够成多少个平行四边形。

思路:开始想使用长度来扫描有多少根,但是好像坐标太大似乎不可行。其实我们可以通过找所有线段的中点的重合个数来计算有几个平行四边形,这种通过别的性质来判断几何关系的思维是解几何题的基础,当作入门?

/** @Date    : 2016-12-02-21.49
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version :
*/ #include<bits/stdc++.h>
#define LL long long
#define PII pair
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 1e6+20; struct yuu
{
double x; double y;
bool operator == (const yuu &a) const
{
return (a.x == this->x) && (a.y == this->y);
}
}s[1010], t[N]; int cmp(yuu a, yuu b)
{
if(a.x != b.x)
return a.x > b.x;
return a.y > b.y;
}
map<pair<double, double> , int>q;
int main()
{ int T;
int cnt = 0;
cin >> T; while(T--)
{
q.clear();
int n;
scanf("%d", &n); for(int i = 1; i <= n; i++)
scanf("%lf%lf", &s[i].x, &s[i].y); int c = 0;
for(int i = 1; i <= n; i++)
{
for(int j = i + 1; j <= n; j++)
{
struct yuu p;
double x = 0, y = 0;
p.x = s[i].x + s[j].x;
p.y = s[i].y + s[j].y;
t[c++] = p;
//q[MP(x, y)]++;
}
}
sort(t, t + c, cmp);
LL ans = 0;
LL k = 0;
for(int i = 0; i < c; i++)
{
//cout << t[i].x << " " << t[i].y << endl;
if(t[i] == t[i + 1])
k++;
else
ans+=(k + 1) *k /2, k = 0;
}
//ans += (k + 1)* k / 2; /*for(auto i = q.begin(); i != q.end(); i++)
{
ans += (i->se)*(i->se - 1)/2;
}*/
/*map<pair<double, double>, int>::iterator it;
for(it = q.begin(); it != q.end(); it++)
ans += (it->se)*(it->se - 1) / 2;*/
printf("Case %d: %lld\n", ++cnt, ans); }
return 0; }
//判断对角线中点出现次数。

LightOJ 1058 - Parallelogram Counting 几何思维的更多相关文章

  1. LightOJ - 1058 - Parallelogram Counting(数学,计算几何)

    链接: https://vjudge.net/problem/LightOJ-1058 题意: There are n distinct points in the plane, given by t ...

  2. 1058 - Parallelogram Counting 计算几何

    1058 - Parallelogram Counting There are n distinct points in the plane, given by their integer coord ...

  3. Light OJ - 1058 Parallelogram Counting(判定平行四边形)

    Description There are n distinct points in the plane, given by their integer coordinates. Find the n ...

  4. Parallelogram Counting(平行四边形个数,思维转化)

    1058 - Parallelogram Counting    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit ...

  5. POJ 1971 Parallelogram Counting (Hash)

          Parallelogram Counting Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6895   Acc ...

  6. lightoj 1148 Mad Counting(数学水题)

    lightoj 1148 Mad Counting 链接:http://lightoj.com/volume_showproblem.php?problem=1148 题意:民意调查,每一名公民都有盟 ...

  7. 计算几何 + 统计 --- Parallelogram Counting

    Parallelogram Counting Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5749   Accepted: ...

  8. 几何+思维 Samara University ACM ICPC 2016-2017 Quarterfinal Qualification Contest K. Revenge of the Dragon

    题目链接:http://codeforces.com/gym/101149/problem/K 题目大意: 给你两个点a,b.一个人在a点,一个人在b点,b点的人要追杀a的点,他的跑步速度是a的两倍. ...

  9. LightOJ - 1148 - Mad Counting

    先上题目: 1148 - Mad Counting   PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: 3 ...

随机推荐

  1. 六: Image Viewer 离线镜像查看器

    参考:http://hadoop.apache.org/docs/r2.6.3/hadoop-project-dist/hadoop-hdfs/HdfsImageViewer.html   离线镜像查 ...

  2. 11.24Daily Scrum

    人员 任务分配完成情况 明天任务分配 王皓南 实现网页上视频浏览的功能.研究相关的代码和功能.990 测试 申开亮 实现网页上视频浏览的功能.研究相关的代码和功能.991 测试 王宇杰 负责后台代码测 ...

  3. [zt]手把手教你写对拍程序(PASCAL)

    谁适合看这篇文章? ACMERS,OIERS或其它参加算法竞赛或需要算法的人 对操作系统并不太熟悉的人 不会写对拍的人 在网上找不到一个特别详细的对拍样例的人 不嫌弃我写的太低幼的人 前言 在NOIP ...

  4. LintCode-7-二叉树的序列化和反序列化

    二叉树的序列化和反序列化 设计一个算法,并编写代码来序列化和反序列化二叉树.将树写入一个文件被称为"序列化",读取文件后重建同样的二叉树被称为"反序列化". 如 ...

  5. redis——持久化方式RDB与AOF分析

    https://blog.csdn.net/u014229282/article/details/81121214 redis两种持久化的方式 RDB持久化可以在指定的时间间隔内生成数据集的时间点快照 ...

  6. 内存交换空间(swap)的构建

    一.使用物理分区构建swap 1.先进行分区的行为. [root@iZ255cppmtxZ ~]# fdisk /dev/xvdb Welcome to fdisk (util-linux ). Ch ...

  7. MAC锁屏不断网(快捷键启用屏保)

    第一步:要设定锁定输入密码的设置,进入'系统偏好设置''安全性与隐私',将选项'进入睡眠或开始屏幕保护程序后'打勾,选'立即'. 第二步:到'launchpad'中的'其他'文件夹打开'Automat ...

  8. 文件上传C:\fakepath\解决方案

    1.设置IE:工具 -> Internet选项 -> 安全 -> 自定义级别 -> 找到“其他”中的“将本地文件上载至服务器时包含本地目录路径”,选中“启用”即可 2.利用js ...

  9. 反向传播算法 Backpropagation Algorithm

    假设我们有一个固定样本集,它包含 个样例.我们可以用批量梯度下降法来求解神经网络.具体来讲,对于单个样例(x,y),其代价函数为:这是一个(二分之一的)方差代价函数.给定一个包含 个样例的数据集,我们 ...

  10. 【bzoj1727】[Usaco2006 Open]The Milk Queue 挤奶队列 贪心

    题目描述 Every morning, Farmer John's N (1 <= N <= 25,000) cows all line up for milking. In an eff ...