fumo星
#include<bits/stdc++.h>
using namespace std;
const int N=1e7;
int n;
struct node{
	double k,b;
}book[N];
bool cmp(node a,node b){
	return a.k<b.k||(a.k==b.k&&a.b<b.b);
}
long long m[1001][2];
long long ff[N];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		long long a,b;
		cin>>a>>b;
		m[i][0]=a;
		m[i][1]=b;
	}
	int flag=0;
	long long cnt=0;
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			double x1=m[i][0],x2=m[j][0],y1=m[i][1],y2=m[j][1];
			double k,b;
			if(x1==x2&&y1==y2){
				flag=1;
				break;
			}
			else if(x1==x2){
				cnt++;
				book[cnt].k=1e9;
				book[cnt].b=x1;
			}
			else if(y1==y2){
				cnt++;
				book[cnt].b=y1;
				book[cnt].k=0;
			}
			else{
				cnt++;
				k=(y1-y2)/(x1-x2);
				b=(x2*y1-x1*y2)/(x2-x1);
				book[cnt].b=b;
				book[cnt].k=k;
			}
		//	cout<<b<<"-"<<k<<endl;
		}
		if(flag==1){
			break;
		}
	}
	long long ans=cnt;
	if(flag==0){
		sort(book+1,book+1+cnt,cmp);
//		cout<<cnt<<endl;
//		for(int i=1;i<=cnt;i++){
//			cout<<book[i].k<<"-"<<book[i].b<<endl;
//		}
		for(int i=1;i<cnt;i++){
			if(book[i].k==book[i+1].k&&book[i].b==book[i+1].b){
				ans--;
			}
		}
	}
	
	if(flag==1){
		cout<<"inf";
	}
	else{
		cout<<ans;
	}
    return 0;
}
也是纯暴力,用排序优化了一下,记得double存k与b,因为n比较小,暴力可行