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:巨挫人求这题的500K左右的代码?谢谢呀~~~~^^^^^^^^不到500 呵呵

Posted by jimoran at 2011-02-04 02:08:11 on Problem 2028
In Reply To:Re:巨挫人求这题的500K左右的代码?谢谢呀~~~~^^^^^^^^不到500 呵呵 Posted by:chhaya at 2009-09-12 21:58:31
396k,0ms,呵呵,做法怪异了些,希望别被喷啊


#include<stdio.h>
#include<string.h>
int main()
{
	bool flag=0;
	int a[105];
	int i,x,y,j,m,t,max=-10,min=1000;
	while(1)
	{
		memset(a,0,sizeof(a));
		max=-10;
		min=1000;
		flag=0;
		scanf("%d%d",&x,&y);
		if(x==y&&y==0)
			break;
		for(j=0;j<x;j++)
		{
			scanf("%d",&t);
			for(i=0;i<t;i++)
			{
				scanf("%d",&m);
				a[m]++;
			}
		}
		for(i=0;i<100;i++)
		{
			if(a[i]>=y)
			{
				if(a[i]==max)
				{
					if(i<min)
					{
						max=a[i];
				        min=i;
				        flag=1;
					}
				}
				else if(a[i]>max)
				{
					max=a[i];
					min=i;
					flag=1;
				}
			}
		}
		if(flag==1)
			printf("%d\n",min);
		else
			printf("0\n");
	}
	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