Bestcoder Round #50 (Div.1) 1002 Run (HDU OJ 5365) Brute Force enumeration + regular polygon verdict

Source: Internet
Author: User

Title: Click Here

Test instructions: give you n points, how many positive polygons (3,4,5,6).

Analysis: The whole point is not a positive pentagon and positive triangular shape and positive hexagonal, so just a violent enumeration of four points to determine whether it is a positive quadrilateral.

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <algorithm>5#include <cmath>6 #definePower (x) ((x) * (x))7 using namespacestd;8 Const Doubleeps=1e-8;9 Const intM = 3e+5;Ten structNode { One     intx, y; A}a[ -]; - intN; - intb[ -]; the intDisintIintj) {//calculate the distance between 2 points -     returnPower (a[i].x-a[j].x) +power (a[i].y-a[j].y); - } - intMain () { +      while(~SCANF ("%d", &N)) { -          for(intI=0; i<n; i++ )    { +scanf"%d%d", &a[i].x, &a[i].y); A         } at         intAns =0; -          for(intI=0; i<n; i++ )    { -              for(intj=i+1; j<n; J + + )  { -                  for(intk=j+1; k<n; k++ )  { -                      for(intl=k+1; l<n; l++ )  { -b[0] =Dis (i, j); inb[1] =Dis (i, k); -b[2] =dis (i, l); tob[3] =Dis (j, k); +b[4] =Dis (j, l); -b[5] = Dis (k, L);//the distance of any 2 points in a quadrilateral theSort (b, + +6 ); *                         if(b[0]==b[3] && Fabs (b[5]-2*b[0]) <eps && b[4]==b[5] )   {//determine if it is a square $ans++;Panax Notoginseng                         } -                     } the                 } +             } A         } theprintf"%d\n", ans); +     } -     return 0; $}

Bestcoder Round #50 (Div.1) 1002 Run (HDU OJ 5365) Brute Force enumeration + regular polygon verdict

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.