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 jxgalq at 2012-07-18 14:43:03 on Problem 1323
In Reply To:哪位大牛帮帮我,为什么总是WA? Posted by:jxgalq at 2012-07-18 14:42:29
#include<stdio.h>
int main()
{
	int a[100],count[100]={0};
  int q,i,j,k,m,n,flag=0,test,pt;
  for(q=1;;q++)
  {
	  scanf("%d %d",&n,&m);
	  if(n==0&&m==0)
	  {break;}
	  pt=m;
    for(i=0;i<m;i++)
	{
	  scanf("%d",&a[i]);
	}
	for(i=0;i<m-1;i++)
	{
	  for(j=i+1;j<m;j++)
	  {
	    if(a[i]>a[j])
		{
		   k=a[i];
		   a[i]=a[j];
		   a[j]=k;
		}
	  }
	}
	for(i=0;i<m;i++)
	{
	  count[i]=a[i];
	}
	for(i=0;i<m;i++)
	{
		  test=a[i];
	      test++;
		  if(i!=0)
		  {pt++;}
       for(j=0;j<=pt;j++)
	   {
		 if(j==pt)
		 {
		   flag++;
		   count[pt]=test;
		   break;
		 }
	     if(test==count[j])
		 {test++;
		 if(test>(n*m))
		 {
		   goto pst;
		 }
		 j=-1;}
	   }
	}
pst:printf("Case %d: %d\n",q,m-flag);
	flag=0;
  }
  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