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

Re:wa到死,自测一百组数据,怎么回事啊,跪求高手

Posted by 20150082 at 2017-07-19 09:47:37 on Problem 1118
In Reply To:wa到死,自测一百组数据,怎么回事啊,跪求高手 Posted by:Matrixking at 2013-02-02 00:07:10
> #include<stdio.h>
> #include<stdlib.h>
> const int maxN=700;
> typedef struct doue
> {
> 	int x,y;
> 	bool operator==(doue b)
> 	{
> 		if(x==b.x&&y==b.y)
> 			return 1;
> 		return 0;
> 	}
> }doue;
> doue pos[maxN],slope[maxN];
> int gcd(int a,int b)
> {
> 	int temp;
> 	while(b)
> 	{
> 		temp=b;
> 		b=a%b;
> 		a=temp;
> 	}
> 	return a;
> }
> int cmp(const void *a,const void *b)
> {
> 	if((*(doue*)a).y!=(*(doue*)b).y)
> 		return (*(doue*)a).y-(*(doue*)b).y;
> 	return (*(doue*)a).x-(*(doue*)b).x;
> }
> int main()
> {
>     freopen("in.txt","r",stdin);
> 	int i,j,N,R,count,ans,k,temp;
> 	while(scanf("%d",&N)!=EOF&&N)
> 	{
> 		for(i=1;i<=N;i++)
> 			scanf("%d%d",&(pos[i].x),&(pos[i].y));
> 		for(i=1,ans=0;i<=N;i++)
> 		{
> 			for(j=1,k=1;j<=N;j++)
> 			{
> 				if(i!=j)
> 				{
> 					slope[k].x=pos[i].x-pos[j].x;
> 					slope[k].y=pos[i].y-pos[j].y;
> 					temp=gcd(slope[k].x>0?slope[k].x:-slope[k].x,slope[k].y>0?slope[k].y:-slope[k].y);
> 					slope[k].x/=temp;
> 					slope[k].y/=temp;
> 					if(slope[k].y<0)
> 					{
> 						slope[k].x=-slope[k].x;
> 						slope[k].y=-slope[k].y;
> 					}
> 					k++;
> 				}
> 			}
> 			qsort(slope,k-1,sizeof(slope[0]),cmp);
> 			if(k-1)
> 			{
> 			   for(j=2,count=1;j<N;j++)
> 				if(slope[j]==slope[j-1])
> 				{
> 					count++;
> 				}
> 				else
> 				{
> 					if(ans<count)ans=count;
> 					count=1;
> 				}
> 			    if(ans<count)ans=count;
> 			}
> 		}
> 		printf("%d\n",ans+1);
> 	}
> 	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