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:请高手指点,两种不同的方法,不同的结果,都是AC的代码

Posted by without2002 at 2008-09-19 20:07:09 on Problem 3427
In Reply To:请高手指点,两种不同的方法,不同的结果,都是AC的代码 Posted by:swpujch at 2007-10-21 16:45:05
#include<iostream>


using namespace std;

int s[30000];

int main(void)
{
	int n,l,i,j;
	while(scanf("%d%d",&n,&l)==2)
	{
		for(i=0;i<n;i++)
			scanf("%d",s+i);
		int min,sum;
		min=0x7fffffff;
		sum=0;
		for(i=0;i<=l;i++)
		{
			for(j=0;j<n;j++)
				s[j]++,sum=sum+s[j]%l;
			if(sum==0)
			{
				min=sum;
				break;
			}
			if(sum<min)
				min=sum;
		}
		printf("%d\n",min);
	}
	return 0;


}

偶头脑晕晕的写出来的,WA了n次

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