标签:
只需要保证不存在三个点在一条直线即可
(包括横坐标相同、纵坐标相同、斜率相同)
(貌似我写的没有考虑到斜率不存在的情况欸~不过AC了)
1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 #include <cmath> 5 #include <string> 6 #include <iostream> 7 #include <vector> 8 #include <list> 9 #include <stack> 10 using namespace std; 11 12 #define REP(n) for(int o=0;o<n;o++) 13 14 pair<int,int> p[205]; 15 bool Do() { 16 int n; 17 if(scanf("%d",&n) == EOF) 18 return false; 19 REP(n) { 20 int x,y; 21 scanf("%d%d",&x,&y); 22 p[o] = pair<int,int>(x,y); 23 } 24 int cnt = 0; 25 for(int i = 0;i < n;i++) 26 for(int j = i + 1;j < n;j++) 27 for(int k = j + 1;k < n;k++) { 28 if(i < j&&j < k) { 29 pair<int,int >a = p[i],b = p[j],c = p[k]; 30 if(!( 31 (a.first == b.first&&a.first == c.first) || 32 (a.second == b.second&&a.second == c.second) || 33 ((double)(a.first - b.first) / (double)(a.second - b.second) == 34 (double)(c.first - b.first) / (double)(c.second - b.second)) 35 )) { 36 cnt++; 37 //printf("%d %d %d\n",i,j,k); 38 } 39 } 40 } 41 printf("%d\n",cnt); 42 43 return true; 44 } 45 46 int main() { 47 while(Do()); 48 return 0; 49 }
标签:
原文地址:http://www.cnblogs.com/ohyee/p/5313754.html