bzoj 1610 [Usaco2008 Feb]Line连线游戏 (计算几何)
http://www.lydsy.com/JudgeOnline/problem.php?id=1610 题意:给出n个点,问有多少条直线,这些之间之间都不平行。 思路:求斜率(注意考虑斜率不存在),看有多少种斜率。 妈蛋。。。。斜率不存在是横坐标相等啊,不是纵坐标啊。。。蠢哭了好么。。。。。。
妈蛋。。。。斜率不存在是横坐标相等啊,不是纵坐标啊。。。蠢哭了好么。。。。。。
妈蛋。。。。斜率不存在是横坐标相等啊,不是纵坐标啊。。。蠢哭了好么。。。。。。
太他妈惨了。。。。
/* ***********************************************
Author :111qqz
Created Time :2016年02月28日 星期日 01时34分35秒
File Name :code/bzoj/1610.cpp
************************************************ */
1#include <cstdio>
2#include <cstring>
3#include <iostream>
4#include <algorithm>
5#include <vector>
6#include <queue>
7#include <set>
8#include <map>
9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#define fst first
14#define sec second
15#define lson l,m,rt<<1
16#define rson m+1,r,rt<<1|1
17#define ms(a,x) memset(a,x,sizeof(a))
18typedef long long LL;
19#define pi pair < int ,int >
20#define MP make_pair
1using namespace std;
2const double eps = 1E-8;
3const int dx4[4]={1,0,0,-1};
4const int dy4[4]={0,-1,1,0};
5const int inf = 0x3f3f3f3f;
6const int N=205;
7const double oo=1897987987;
8struct node
9{
10 double x,y;
1 double getk(node b)
2 {
3 return (y-b.y)/(x-b.x);
4 }
1}p[N];
2double k[40005];
3int n;
1int dblcmp(double d)
2{
3 return d<-eps?-1:d>eps;
4}
5int main()
6{
7 #ifndef ONLINE_JUDGE
8 freopen("code/in.txt","r",stdin);
9 #endif
1 ios::sync_with_stdio(false);
2 cin>>n;
3 for ( int i = 1 ; i <= n ; i++)
4 {
5 cin>>p[i].x>>p[i].y;
6 }
1 int cnt = 0 ;
2 for ( int i = 1 ; i <= n-1 ;i++)
3 {
4 for ( int j = i+1 ; j <= n ; j++)
5 {
6 ++cnt;
7 // cout<<"i:"<<i<<" p[i].y:"<<p[i].y<<" j:"<<j<<" p[j].y:"<<p[j].y<<endl;
8 if (dblcmp(p[i].x-p[j].x)==0) k[cnt]=oo;
9 else k[cnt] = p[i].getk(p[j]);
10 }
11 }
1 //check k
2// for ( int i = 1 ; i <= cnt ; i++) cout<<k[i]<<endl;
3 sort(k+1,k+cnt+1);
1 int ans = 0 ;
2 for ( int i = 1 ; i <= cnt ; i++)
3 {
4 if (i==1||dblcmp(k[i]-k[i-1])!=0) ans++;
5 }
cout<<ans<<endl;
1 #ifndef ONLINE_JUDGE
2 fclose(stdin);
3 #endif
4 return 0;
5}