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 testing at 2003-06-02 11:54:39 on Problem 1011
#include <iostream.h>

void main()
{
	int i,j,k,m,n,p,s,q,temp,total,flag;
	int a[100];
	int b[100];
	int an[1000];
	for (s=1;;s++)
	{
		total=0;
		cin >>n;
		if (n==0)break;
		flag=0;
		for (p=1;p<=n;p++)
		{
			cin >>a[p];
			total=total+a[p];
			if (a[p]<=0||a[p]>50)
			{
				flag=1;
			}
		}
		if (flag==1)
		{
			an[s]=0;
			continue;
		}
		for (p=1;p<=n;p++)
		{
			for (q=p;q<=n;q++)
			{
				if (a[p]<a[q])
				{
					temp=a[p];
					a[p]=a[q];
					a[q]=temp;
				}
			}
		}
		for (j=total;j>=a[1];j--)
		{
			for (p=1;p<=n;p++)b[p]=a[p];
			if ((total%j)==0)p=j;
			else
			{
				continue;
			}
		for (i=1;i<=1000;i++)
		{
			p=j;
			for (k=1;k<=n;k++)
			{
				if (p>=b[k])
				{
					p=p-b[k];
					b[k]=0;
				}
				if (p==0)break;
			}
			m=0;
			for (k=1;k<=n;k++) m=m+b[k];
			if (m==0)
			{
				an[s]=j;
				break;
			}
			else
			{
				if (p!=0) break;
			}
		}
	}
	}
	for (p=1;p<=s-1;p++) 
	{
		if (an[p]!=0)cout<<an[p]<<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