Hdu 5365 Run (BC 50 B) (number of quadrilateral), hdu5365
I was prepared to go to bed, but I still couldn't help thinking about it because I have read the answer,
Question: it is to give you some coordinates, all of which are integers. Ask for the number of positive polygon. The official question is that people on earth know that the integer coordinates are not in a positive triangle, a positive Pentagon and a hexagonal shape... But I don't know... I will know later...
Therefore, this question can be directly violent, and the number of the positive quadrilateral is obtained. Here, we can determine whether the positive quadrilateral uses four sides to be equal, and the two sides are equal on the diagonal and the sides are smaller than the diagonal lines, I don't know if this is the right Quadrilateral (...)
Put the Code:
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<vector>#include<set>#include<string>#include<algorithm>using namespace std;int solve(int a,int b,int c,int d){return (a-c)*(a-c)+(b-d)*(b-d);}int cmp(const void *a,const void *b){return *(int *)a - *(int *)b;}int main(){int n,i,j,k,p;int a[25],b[25],c[25];while(cin >> n){for(i=1; i<=n; i++)cin >> a[i] >> b[i];int ans = 0;for(i=1; i<=n; i++)for(j=i+1; j<=n; j++)for(k=j+1; k<=n; k++)for(p=k+1; p<=n; p++){c[0] = solve(a[i],b[i],a[k],b[k]);c[1] = solve(a[i],b[i],a[j],b[j]);c[2] = solve(a[i],b[i],a[p],b[p]);c[3] = solve(a[j],b[j],a[k],b[k]);c[4] = solve(a[j],b[j],a[p],b[p]);c[5] = solve(a[k],b[k],a[p],b[p]);qsort(c,6,sizeof(c[0]),cmp);if(c[0]==c[1]&&c[1]==c[2]&&c[2]==c[3]&&c[4]==c[5])ans++;}cout << ans << endl;} return 0;}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.