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 2014CCUTlch at 2015-09-12 18:58:21 on Problem 1477
#include<iostream>
#include<stdlib.h>
using namespace std;

int main()
{
	int n,*p,i;
	int s=0;
	int num=0;
	while(cin>>n&&n)
	{
		++s;
		p=(int *)calloc(n,sizeof(int)); 
		int sum=0;
		for(i=0;i<n;++i)
		{
			cin>>p[i];
			sum+=p[i];
		}
		sum/=n;
		
		for(i=0;i<n;++i)
		{
			if(p[i]>sum)
				num+=p[i]-sum;
		}
	}
	cout<<"Set #"<<s<<endl;
	cout<<"The minimum number of moves is "<<num<<"."<<endl;
	cout<<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