1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
#include <iostream> #include <math.h> //#include <string> using namespace std; struct point{ double x; double y; }p[101]; int isIsosceles(int a,int b,int c) { //dist of p[a],p[b] double d1 = sqrt((p[a].x-p[b].x)*(p[a].x-p[b].x) + (p[a].y-p[b].y)*(p[a].y-p[b].y)); double d2 = sqrt((p[c].x-p[b].x)*(p[c].x-p[b].x) + (p[c].y-p[b].y)*(p[c].y-p[b].y)); double d3 = sqrt((p[a].x-p[c].x)*(p[a].x-p[c].x) + (p[a].y-p[c].y)*(p[a].y-p[c].y)); //cout<<d1<<" "<<d2<<" "<<d3<<"\n"; if((d1+d2)<=d3 || (d3+d1)<=d2 || (d3+d2)<=d1) return 0; else if(d1==d2 && d2==d3 && d1==d3) return 0; else if(d1!=d2 && d2!=d3 && d1!=d3) return 0; return 1; } int main() { int n; double a,b; int Isosceles; while(cin>>n) { for(int i=0;i<n;i++) { cin>>a>>b; p[i].x=a; p[i].y=b; } Isosceles = 0; for(int i=0;(i-2)<n;i++) { for(int j=i+1;(j-1)<n;j++) { for(int k=j+1;k<n;k++) { //cout<<i<<","<<j<<","<<k<<"\n"; if(isIsosceles(i,j,k)) Isosceles++; } } } cout<<Isosceles<<"\n"; } return 0; } |