acm几何
fzu 2231,N个点求构成的平行四边行个数。 题意简重点在优化上
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map> using namespace std;
const int maxn = ; struct node
{
int x,y;
}point[maxn]; vector<pair<double,double> >vec; int n; bool cmp(pair<double,double>a,pair<double,double>b)
{
if(a.first==b.first){
return a.second<b.second;
}
return a.first<b.first;
} int main()
{
int n;
while(~scanf("%d",&n))
{
vec.clear();
for(int i=;i<n;i++)
{
scanf("%d%d",&point[i].x,&point[i].y);
}
for(int i=;i<n;i++)
{
for(int j=i+;j<n;j++)
{
double xx=(point[i].x+point[j].x)/.;
double yy=(point[i].y+point[j].y)/.;
vec.push_back(make_pair(xx,yy));
}
}
int ans=;
int num=;
sort(vec.begin(),vec.end(),cmp);
for(int i=;i<vec.size();i++){
if(vec[i].first==vec[i-].first&&vec[i].second==vec[i-].second){
num++;
}
else{
ans+=(num*(num-)/);
num=;
}
}
printf("%d\n",ans);
} return ;
}
acm几何的更多相关文章
- woj1016 cherry blossom woj1017 Billiard ball 几何
title: woj1016 cherry blossom date: 2020-03-18 20:00:00 categories: acm tags: [acm,几何,woj] 几何题,判断给出的 ...
- woj1013 Barcelet 字符串 woj1014 Doraemon's Flashlight 几何
title: woj1013 Barcelet 字符串 date: 2020-03-18 18:00:00 categories: acm tags: [acm,字符串,woj] 字符串,字典序. 1 ...
- ACM: CodeForces 140A New Year Table-数学几何
CodeForces 140A New Year Table Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d ...
- 几何+思维 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的两倍. ...
- 北京师范大学第十五届ACM决赛-重现赛E Euclidean Geometry (几何)
链接:https://ac.nowcoder.com/acm/contest/3/E 来源:牛客网 Euclidean Geometry 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ ...
- ACM: FZU 2110 Star - 数学几何 - 水题
FZU 2110 Star Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Pr ...
- ACM学习历程—Rotate(HDU 2014 Anshan网赛)(几何)
Problem Description Noting is more interesting than rotation! Your little sister likes to rotate thi ...
- ACM失败之路
校赛打完,已过四月,该是准备背起行囊,踏上考研之路了,自然,得先阔别一下ACM了,想起这几年ACM路,感慨颇多,不得不一诉心肠,与大家分享一下我的ACM历程,如果有人能从此文获取一些益处,那我就很欣慰 ...
- 【转】ACM训练计划
[转] POJ推荐50题以及ACM训练方案 -- : 转载自 wade_wang 最终编辑 000lzl POJ 推荐50题 第一类 动态规划(至少6题, 和 必做) 和 (可贪心) (稍难) 第二类 ...
随机推荐
- MYSQL之库操作
一.系统数据库 information_schema :虚拟库,不占用磁盘空间,存储的是数据库启动后的一些参数,如用户表信息.列信息.权限信息.字符信息等 mysql:核心数据库,里面包含用户.权限. ...
- 高级控件 popwindow 与gridview的组合应用
Gridview 的布局设置 <GridView android:layout_width="wrap_content" android:layout_height=&quo ...
- 剑指offer-二叉树的下一个节点
题目描述 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回.注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针. 解题思路 分情况考虑如下: 若该节点为空,则直 ...
- Hadoop MR编程
Hadoop开发job需要定一个Map/Reduce/Job(启动MR job,并传入参数信息),以下代码示例实现的功能: 1)将一个用逗号分割的文件,替换为“|”分割的文件: 2)对小文件合并,将文 ...
- 定义一个方法get_page(url),url参数是需要获取网页内容的网址,返回网页的内容。提示(可以了解python的urllib模块)
定义一个方法get_page(url),url参数是需要获取网页内容的网址,返回网页的内容.提示(可以了解python的urllib模块) import urllib.request def get_ ...
- Text-查找文本
from tkinter import * master=Tk() text=Text(master,width=30,height=5) text.pack() text.insert(INSERT ...
- js常用正则表达式表单验证代码
方法一: var re=/正则表达式/; re.test($("txtid").val()) 方法二: $("txtid").val.match(/正则 ...
- C/C++下调用matlab函数操作说明
1.matlab的安装 连接:http://pan.baidu.com/s/1qXuF7aO 安装32位版本的matlab(在目录下bin文件夹中有两个文件夹,选择win32文件夹下的setup进行安 ...
- opencv2.4.9卸载安装
1.安装opencv2.4.9过程中遇到的问题. 1.使用 sudo apt-get install libopencv-dev 安装OpenCV 2.4.9 发现版本为2.4.8,故卸载重装. 查看 ...
- java--Iterator迭代问题:集合并发访问异常
用Iterator对数组进行迭代后,如果在迭代过程中对数组进行增加元素操作(这里iterator本身没有提供增加操作方法)时,就会抛出并发访问异常: 异常如下: Exception in thread ...