zoukankan      html  css  js  c++  java
  • 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;
    }
    

      

  • 相关阅读:
    DotText源码阅读
    看来这世界看得太清楚了也未必是种好事呢~~~~~~~
    在Init之前究竟执行了什么?
    孙子兵法
    Excel区域重命名
    Getbuffer ReleaseBuffer Cstring
    批量删除svn标志
    VB制作网页自动填表(强烈推荐)
    GetModuleFileName
    ansi编码
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/7246516.html
Copyright © 2011-2022 走看看