Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WA啊!大牛们指点指点!

Posted by 200609020331 at 2008-11-25 17:00:16 on Problem 3668
#include<iostream>
using namespace std;
struct point
{
	int x,y;
}s[250];
int mycompare(const void *elem1,const void *elem2)
{
	return *(double *)elem1-*(double *)elem2;
}
int main()
{
	int n,i,j,accouts=0,t;
	bool flag=false;
	double k[41000],m=100000000.0;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>s[i].x>>s[i].y;
	t=0;
	for(i=1;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			if(s[i].x != s[j].x)
			{
				k[t]=(double)(s[j].y-s[i].y)/(double)(s[j].x-s[i].x);
				t++;
			}
			else if(s[i].x==s[j].x)
			{
			  k[t]=m;
			  t++;
			}
		}
	}
    qsort(k,t,sizeof(double),mycompare);
	cout<<endl;
   	for(i=0;i<t;i++)
	{
		if(k[i]==k[i+1])
			accouts++;
	}
	if(t==0)
		cout<<"0"<<endl;
    else
	  cout<<t-accouts<<endl;
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator