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 Mr109 at 2011-10-08 15:32:25 on Problem 1118
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int n,t,s,m(1);
int data[710][2];
double ans[710][2];
void deal(int a,int b)
{
	double k;
	bool flag=true;
	if (data[b][0]==data[a][0])
		k=99999999;
	else
	k=((double)(data[b][1]-data[a][1]))/(data[b][0]-data[a][0]);
	for (int i=0;i!=s;++i)
		if (abs(ans[i][0]-k)<1e-8)
		{
			ans[i][1]++;
			flag=false;
		}
	if (flag)
	{
		ans[s][0]=k;
		ans[s][1]=2;
		s++;
	}
}
int main()
{
	while (cin>>n,n!=0)
	{
		m=1;
	for (int i=0;i!=n;++i)
		cin>>data[i][0]>>data[i][1];
	for (int i=0;i!=n-1;++i)
		for (int j=i+1;j!=n;++j)
			if (data[i][0]>data[j][0])
			{
				t=data[i][0];
				data[i][0]=data[j][0];
				data[j][0]=t;
				t=data[i][1];
				data[i][1]=data[j][1];
				data[j][1]=t;
			}
	for (int i=0;i!=n-1;++i)
	{
		s=0;
		for (int j=i+1;j!=n;++j)
			deal(i,j);
		for (int j=0;j!=s;++j)
			if (ans[j][1]>m)
				m=int(ans[j][1]);
	}
	cout<<m<<endl;
	}
}

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