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. canvas学习(四):高级属性

    一:阴影 示例:绘制一个带有阴影的正方形 var canvas = document.getElementById("myCanvas") var ctx = canvas.get ...

  2. Where to go from here

    Did you get through all of that content? Congratulations! You've learnt the fundamentals of algorith ...

  3. Java中的线程的优先级

    Java 中线程优先级简介: 1. Java 提供一个线程调度器来监控程序中启动后进入就绪状态的所有线程. 按照线程的优先级决定应该调度哪个线程来执行. 2. 线程的优先级用数字表示, 范围从 1 到 ...

  4. Cstring, TCHAR*, char*的转换

    最近老用到Cstring, TCHAR*, char*的转换. 找到一篇写得蛮详细的. 引用过来, 方便自己以后查阅. char是类型TCHAR也是!不过他可以通过是否定义了UNICODE宏来判断到底 ...

  5. iOS- iPad里有趣的UIPopoverController

    效果: 1.对UIPopoverController的简单概述 1.1 UIPopoverController是在iPad开发中常用的一个组件(在iPhone上不允许使用),使用非常简单   1.2 ...

  6. OSPF学习中的问题

    OSPF对接两方,对设置的要求,哪些参数必须相同 (HELLO &dead interval, area ID, authentation, 末节区域(option中的E位), network ...

  7. 3ds Max学习日记(五)

      把实验室要用的小工具做了出来后,忙里偷闲,把第四章没看完的视频看完了.修改器(modifier)什么的还是挺好玩的.   FFD,车削,倒角,倒角剖面,对称,挤出,晶格,扭曲,融化,弯曲,网格平滑 ...

  8. 网众远程修改ip、dns

    修改文件 修改ip vi /etc/rc.d/rc.inetd1.config IPADDR[0] 对应第一块网卡的ip 修改dns vi /etc/resolv.conf nameserver 21 ...

  9. phpcmsv9 同时调用多个栏目的文章标签

    V9版本默认好像没有多栏目调用的标签,例如我用{pc:content action="lists" catid ="6,7,8,9,10" num=" ...

  10. Qt MetaObject System详解

    网上的资源比较乱,该文章整理自地址:http://www.xuebuyuan.com/735789.html Qt meta-object系统基于三个方面: 1.QObject提供一个基类,方便派生类 ...