zoukankan      html  css  js  c++  java
  • HDU 6055 Regular polygon 暴力枚举

      题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6055

      题目描述: 给你n个整数点, 问你有多少个点组成了正多边形?

      解题思路: 因为是整数点,所以只能组成正方形,固定两个点, 另外两个点的坐标如图所示

       

      代码: 

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <string>
    #include <algorithm>
    using namespace std;
    
    int a[500][500];
    const int maxn = 205;
    
    int main() {
        int n, x, y;
        while( ~scanf( "%d", &n ) ) {
            memset(a, 0, sizeof(a));
            for( int i = 0; i < n; i++ ) {
                scanf( "%d%d", &x, &y );
                x += 100;
                y += 100;
                a[x][y] = 1;
            }
            int res = 0;
            for( int i = 0; i < maxn; i++ ) {
                for( int j = 0; j < maxn; j++ ) {
                    if( a[i][j] ) {
                        a[i][j] = 0;
                        for( int p = i; p < maxn; p++ ) {
                            for( int q = j+1; q < maxn; q++ ) {
                                if( a[p][q] ) {
                                    int xdif = p - i;
                                    int ydif = q - j;
                                    if( a[p+ydif][q-xdif] && a[i+ydif][j-xdif] ) {
                                        res++;
    //                                    cout << i << " " << j << endl;
    //                                    cout << p << " " << q << endl;
    //                                    cout << p+ydif << " " << q-xdif << endl;
    //                                    cout << i+ydif << " " << j-xdif << endl;
                                    }
                                }
                            }
                        }
                        a[i][j] = 1;
                    }
                }
            }
            printf( "%d\n", res );
        }
        return 0;
    }
    View Code

      思考: 这是一道计算机和的水题, 昨天第一次知道了高数的重要性, 下个学期应该开始复习数学了

  • 相关阅读:
    基于ARP的网络扫描工具netdiscover
    渗透测试集成环境Faraday
    NBNS扫描工具nbtscan-unixwiz
    分享Kali Linux 2017年第18周镜像文件
    Hat's Fibonacci
    N!
    A + B Problem II(大数加法)
    产生冠军(拓扑排序)
    确定比赛名次
    Legal or Not(模板题)
  • 原文地址:https://www.cnblogs.com/FriskyPuppy/p/7249106.html
Copyright © 2011-2022 走看看