[HDOJ5365]Run

來源:互聯網
上載者:User

標籤:

題目連結: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\n", solve());58     }59 }

 

[HDOJ5365]Run

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.