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. NFC学习总结二

    移动支付这事情热了总归还是会回归理性,就如同之前的10几年间的几次轮回一样.字面上看,移动支付比支付大也不大可能,有相同,有扩展,有交集有不通才是. NFC这事情也是说了快十年了,真心希望它能回归到其 ...

  2. 2017-2018-2 20172323 『Java程序设计』课程 结对编程练习_四则运算

    结对编程的好丽友 - 20172323 王禹涵:中缀转后缀 - 20172314 方艺雯:后缀表达式的计算 - 20172305 谭鑫:中缀表达式的输出 需求分析 能随机生成由使用者确定的任意多道四则 ...

  3. C语言 内存分配 地址 指针 数组 参数 实例解析

    . Android源码看的鸭梨大啊, 补一下C语言基础 ... . 作者 : 万境绝尘 转载请注明出处 : http://blog.csdn.net/shulianghan/article/detai ...

  4. LintCode-56.两数之和

    两数之和 给一个整数数组,找到两个数使得他们的和等于一个给定的数 target. 你需要实现的函数twoSum需要返回这两个数的下标, 并且第一个下标小于第二个下标.注意这里下标的范围是 1 到 n, ...

  5. iOS开发UIApplication用法

    1.简单介绍 (1)UIApplication对象是应用程序的象征,一个UIApplication对象就代表一个应用程序. (2)每一个应用都有自己的UIApplication对象,而且是单例的,如果 ...

  6. IIS安装出现“安装程序无法复制文件CONVLOG.EX_”的解决办法

    重新安装了一次IIS,结果就在重新安装的时候,出现安装程序无法复制文件CONVLOG.EX_,上网找了找资料,是因为secedit.sdb 数据库的问题,既然是因为这个文件的问题,那么我们就可以使用w ...

  7. 代码编写规范Asp.Net(c#)

    1        目的 为了统一公司软件开发的设计过程中关于代码编写时的编写规范和具体开发工作时的编程规范,保证代码的一致性,便于交流和维护,特制定此规范. 2        范围 本规范适用于开发组 ...

  8. Python爬虫requests判断请求超时并重新发送请求

     下面是简单的一个重复请求过程,更高级更简单的请移步本博客: https://www.cnblogs.com/fanjp666888/p/9796943.html  在爬虫的执行当中,总会遇到请求连接 ...

  9. 【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 ...

  10. BZOJ4754 JSOI2016独特的树叶(哈希)

    判断两棵无根树是否同构只需要把重心提作根哈希即可.由于只添加了一个叶子,重心的位置几乎不发生偏移,所以直接把两棵树的重心提起来,逐层找哈希值不同且对应的两子树即可.被一个普及组子问题卡一年. #inc ...