目录:
题目:
分析:
这道题不需要什么高端的算法,只要运用些数论知识——斜率就好了
代码:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<ctime>
#include<iomanip>
#include<string>
#include<bitset>
#include<deque>
#include<set>
#define LL long long
#define h happy
#define XJQ 0x7f7f7f7f
using namespace std;
inline LL read() {
LL d=0,f=1;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
return d*f;
}
double slope[3001];
int x[3001][3];
int main()
{
int n=read();
for(int i=1;i<=n;i++) x[i][1]=read(),x[i][2]=read();
LL len,s=(n-1)*(n-2);
s=s*n/6;
for(int i=1;i<n-1;i++)
{
len=0;
for(int j=i+1;j<=n;j++)
if(x[i][1]-x[j][1]!=0) slope[++len]=(double)(x[i][2]-x[j][2])/(double)(x[i][1]-x[j][1]);
else slope[++len]=XJQ;
sort(slope+1,slope+1+len);
int t=1;
for(int j=2;j<=len;j++)
if(slope[j-1]==slope[j]) t++;
else s-=(t-1)*t/2,t=1;
s-=(t-1)*t/2;
}
cout<<s;
return 0;
}