zoukankan      html  css  js  c++  java
  • [HDOJ5365]Run

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

    众所周知,整点是围不成正三角形正五边形正六边形的,所以我们只需暴力出它可以围成几个正四边形。

     1 #include <cstdio>
     2 #include <cstdlib>
     3 #include <cstring>
     4 #include <algorithm>
     5 #include <iostream>
     6 #include <cmath>
     7 #include <cctype>
     8 #include <queue>
     9 #include <map>
    10 #include <set>
    11 #include <stack>
    12 #include <list>
    13 #include <vector>
    14 
    15 using namespace std;
    16 
    17 typedef struct Node {
    18     int x;
    19     int y;
    20 };
    21 Node po[22];
    22 int edge[11];
    23 int n;
    24 
    25 int dis(int x, int y) {
    26     return x * x + y * y;
    27 }
    28 int solve() {
    29     memset(edge, 0, sizeof(edge));
    30     int ans = 0;
    31     for(int i = 0; i < n; i++) {
    32         for(int j = i+1; j < n; j++) {
    33             for(int p = j+1; p < n; p++) {
    34                 for(int q = p+1; q < n; q++) {
    35                     edge[0] = dis(po[i].x-po[j].x, po[i].y-po[j].y);
    36                     edge[1] = dis(po[i].x-po[p].x, po[i].y-po[p].y);
    37                     edge[2] = dis(po[i].x-po[q].x, po[i].y-po[q].y);
    38                     edge[3] = dis(po[j].x-po[p].x, po[j].y-po[p].y);
    39                     edge[4] = dis(po[j].x-po[q].x, po[j].y-po[q].y);
    40                     edge[5] = dis(po[p].x-po[q].x, po[p].y-po[q].y);
    41                     sort(edge, edge+6);
    42                     if(edge[0] == edge[1] && edge[1] == edge[2] && edge[2] == edge[3] && edge[4] == edge[5]) {
    43                         ans++;
    44                     }
    45                 }
    46             }
    47         }
    48     }
    49     return ans;
    50 }
    51 int main() {
    52     // freopen("in", "r", stdin);
    53     while(~scanf("%d", &n)) {
    54         for(int i = 0; i < n; i++) {
    55             scanf("%d %d", &po[i].x, &po[i].y);
    56         }
    57         printf("%d
    ", solve());
    58     }
    59 }
  • 相关阅读:
    时间戳(UnixTimestamp)与 《2038年问题》
    端口相关命令
    Ubuntu中的在文件中查找和替换命令
    A Reusable Aspect for Memory Profiling
    acc文件的运行
    A Reusable Aspect for Memory Allocation Checking
    ACC常用语句
    aspectC++常用命令
    c++调用DOS命令,不显示黑屏
    fopen文件目录问题
  • 原文地址:https://www.cnblogs.com/kirai/p/4781596.html
Copyright © 2011-2022 走看看