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 dengd at 2010-04-11 11:32:41 on Problem 3427
#include<iostream>
using namespace std;
int main()
{
	int l,n;
	int a[30002];
	while(cin>>n>>l)
	{
		int i;
		int sum=0;
		for(i=0;i<n;i++){
			cin>>a[i];
			sum+=a[i]%l;
		}
		if(sum==0){
			cout<<sum<<endl;
			continue;
		}
		int j;
		sum=0;
		int min=999999999;
			for(j=0;j<=l;j++)
			{
				for(i=0;i<n;i++){
					a[i]++;
					sum+=a[i]%l;
				}
				if(sum==0)
					break;
				if(sum<min)
					min=sum;
			}
			cout<<min<<endl;
	}
	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