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