• HDU 6055 Regular polygon (暴力)


    题意,二维平面上给N个整数点,问能构成多少个不同的正多边形。

    析:容易得知只有正四边形可以使得所有的顶点为整数点。所以只要枚举两个点,然后去查找另外两个点就好。

    代码如下:

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include <cstdio>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    #include <cstring>
    #include <set>
    #include <queue>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <cctype>
    #include <cmath>
    #include <stack>
    #include <sstream>
    #include <list>
    #define debug() puts("++++");
    #define gcd(a, b) __gcd(a, b)
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define freopenr freopen("in.txt", "r", stdin)
    #define freopenw freopen("out.txt", "w", stdout)
    using namespace std;
    
    typedef long long LL;
    typedef unsigned long long ULL;
    typedef pair<int, int> P;
    const int INF = 0x3f3f3f3f;
    const double inf = 0x3f3f3f3f3f3f;
    const double PI = acos(-1.0);
    const double eps = 1e-8;
    const int maxn = 500 + 10;
    const LL mod = 1e9 + 7;
    const int dr[] = {-1, 0, 1, 0};
    const int dc[] = {0, 1, 0, -1};
    const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
    int n, m;
    const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    inline bool is_in(int r, int c){
      return r > 0 && r <= n && c > 0 && c <= m;
    }
    
    map<P, int> mp;
    P p[maxn];
    
    P solve(const P &p1, const P &p2){
      int detx = p2.first - p1.first;
      int dety = p2.second - p1.second;
      return P(p1.first-dety, p1.second+detx);
    }
    
    int main(){
      while(scanf("%d", &n) == 1){
        mp.clear();
        for(int i = 0; i < n; ++i){
          scanf("%d %d", &p[i].first, &p[i].second);
          mp[p[i]] = true;
        }
    
        int ans = 0;
        for(int i = 0; i < n; ++i){
          for(int j = 0; j < n; ++j){
            if(i == j)  continue;
            P p1 = solve(p[i], p[j]);
            if(!mp.count(p1))  continue;
            P p2 = solve(p1, p[i]);
            if(!mp.count(p2))  continue;
            ++ans;
          }
        }
        printf("%d
    ", ans/4);
      }
      return 0;
    }
    

      

  • 相关阅读:
    ABAP常用快捷键
    UDP协议的几个特性
    HTTP协议的工作原理
    SAP Memory与ABAP Memory
    Solution Manager Key
    内表的CLEAR、REFRESH、FREE
    ABAP变量的几种可见范围
    Oracle的表空间、数据文件、用户
    SAP ECC6.0 IDES在Win7 X64上的安装
    SAP激活中文语言包
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/7246516.html
Copyright © 2020-2023  润新知