Regular polygon

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2004    Accepted Submission(s): 795

Problem Description
On
a two-dimensional plane, give you n integer points. Your task is to
figure out how many different regular polygon these points can make.
Input
The
input file consists of several test cases. Each case the first line is a
numbers N (N <= 500). The next N lines ,each line contain two number
Xi and Yi(-100 <= xi,yi <= 100), means the points’ position.(the
data assures no two points share the same position.)
Output
For each case, output a number means how many different regular polygon these points can make.
 
Sample Input
4
0 0
0 1
1 0
1 1
6
0 0
0 1
1 0
1 1
2 0
2 1
Sample Output
1
2
题意:给你n个整数点 问你组成正多边形的有几组
因为题目给的是整数点 只要正四边形才能是整点
所以我们只要枚举其中任意两个点 利用旋转公式可以得到其它两个点 判断其他两个点是否存在就可以了
旋转公式是 x=xcos@-ysin@
          y=xsin@-ycos@;
 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<string.h>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
typedef long long ll;
typedef unsigned long long LL;
using namespace std;
const double PI=acos(-1.0);
const double eps=0.0000000001;
const int N=+;
struct node{
int x,y;
}a[N];
int vis[N][N];
int main(){
int n;
while(scanf("%d",&n)!=EOF){
memset(vis,,sizeof(vis));
for(int i=;i<=n;i++){
scanf("%d%d",&a[i].x,&a[i].y);
vis[a[i].x+][a[i].y+]=i;
}
ll ans=;
int x,y;
int xx,yy;
int len;
for(int i=;i<=n;i++){
for(int j=i+;j<=n;j++){
if(i==j)continue;
x=(a[j].y-a[i].y)+a[i].x;
y=(a[j].x-a[i].x)*(-)+a[i].y;
xx=-(a[i].y-a[j].y)+a[j].x;
yy=(a[i].x-a[j].x)+a[j].y;
int t1=vis[x+][y+];
int t2=vis[xx+][yy+];
if(t1&&t2)ans++;
x=-(a[j].y-a[i].y)+a[i].x;
y=(a[j].x-a[i].x)+a[i].y;
xx=(a[i].y-a[j].y)+a[j].x;
yy=-(a[i].x-a[j].x)+a[j].y;
int t3=vis[x+][y+];
int t4=vis[xx+][yy+];
if(t3&&t4)ans++;
}
}
// cout<<ans<<endl;
ans=ans/;
printf("%I64d\n",ans);
}
}

2017 Multi-University Training Contest - Team 2 &hdu 6055 Regular polygon的更多相关文章

  1. HDU 6055 - Regular polygon | 2017 Multi-University Training Contest 2

    /* HDU 6055 - Regular polygon [ 分析,枚举 ] 题意: 给出 x,y 都在 [-100, +100] 范围内的 N 个整点,问组成的正多边形的数目是多少 N <= ...

  2. 2017 Multi-University Training Contest - Team 2 &&hdu 6050 Funny Function

    Funny Function Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  3. 2017 Multi-University Training Contest - Team 2 &&hdu 6053 TrickGCD

    TrickGCD Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total ...

  4. 2017 Multi-University Training Contest - Team 2&&hdu 6047 Maximum Sequence

    Maximum Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  5. HDU 6055 Regular polygon

    Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  6. 【2017 Multi-University Training Contest - Team 7 && hdu 6121】Build a tree

    [链接]点击打开链接 [题意] 询问n个点的完全k叉树,所有子树节点个数的异或总和为多少. [题解] 考虑如下的一棵k=3叉树,假设这棵树恰好有n个节点. 因为满的k叉树,第i层的节点个数为k^(i- ...

  7. 【 2017 Multi-University Training Contest - Team 9 && hdu 6162】Ch’s gift

    [链接]h在这里写链接 [题意] 给你一棵树,每个节点上都有一个权值. 然后给你m个询问,每个询问(x,y,a,b); 表示询问x->y这条路径上权值在[a,b]范围内的节点的权值和. [题解] ...

  8. HDU 6055 Regular polygon —— 2017 Multi-University Training 2

    Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  9. 【2017多校训练2+计算几何+板】HDU 6055 Regular polygon

    http://acm.hdu.edu.cn/showproblem.php?pid=6055 [题意] 给定n个格点,问有多少个正多边形 [思路] 因为是格点,只可能是正方形 枚举正方形的对角线,因为 ...

随机推荐

  1. centos7下手动制作trove镜像

    获取镜像 [root@bldattet1 ~]#  wget http://mirrors.aliyun.com/centos/7.5.1804/isos/x86_64/CentOS-7-x86_64 ...

  2. jQuery——事件操作

    事件绑定 1.简单事件绑定 $("button").click(function () {})//可重复绑定,不会被层叠 2.bind():不推荐使用 $("button ...

  3. RTL Compiler之synthesis steps

    1 synthesis steps 1) Search Paths rc:/> set_attribute lib_search_path path / rc:/> set_attribu ...

  4. Ubuntu下获取内核源码

    查看当前系统使用的内核版本: apt-cache search linux-source 输出如下: linux-source - Linux kernel source with Ubuntu pa ...

  5. POJ_3013_最短路

    Big Christmas Tree Time Limit: 3000MS   Memory Limit: 131072K Total Submissions: 23630   Accepted: 5 ...

  6. Linux 下phpstudy的安装使用补充说明

    (1)使用方法 在终端中使用sudo 或者 使用管理员账号运行 phpstudy start 开启 (2)命令列表: phpstudy start | stop | restart        开启 ...

  7. ThinkPHP5.1安装

    安装 ====== 按照官方的推荐方式,推荐使用composer方式安装 TP5.1环境要求 PHP >= 5.6.0 PDO PHP Extension MBstring PHP Extens ...

  8. Dijkstra算法求最短路径

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h&g ...

  9. 【IntelliJ IDEA】idea上安装Translation插件后,需要AppKey才能生效的解决方案

    使用idea安装的翻译插件translation,但是使用的时候并不友好 无奈,如果想使用翻译软件并且更方便的话,可以如下: 可以选择将translation进行卸载 清除缓存并进行重启 然后再启动之 ...

  10. [BZOJ 3221][Codechef FEB13] Obserbing the tree树上询问

    [BZOJ 3221]Obserbing the tree树上询问 题目 小N最近在做关于树的题.今天她想了这样一道题,给定一棵N个节点的树,节点按1~N编号,一开始每个节点上的权值都是0,接下来有M ...