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

HELP 一直WA啊

Posted by 20124260 at 2013-09-23 22:00:21 on Problem 1477
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define MAX 10
int a[MAX];
int main()
{
	int ca = 0;
	int n = 0;

	while(scanf("%d",&n)==1&&n != 0)
	{
		ca++;
		int ave = 0;
		for(int i = 0;i < n;i++)
		{
			scanf("%d",&a[i]);
			ave+=a[i];
		}
		ave/=n;
		int ans = 0;
		for(int j=0;j < n;j++)
		{
			if(a[j]>ave)
			{
				ave = a[j] - ave;
				ans++;
			}
		}
		printf("Set #%d\n",ca);
		printf("The minimum number of moves is %d.\n\n",ans);
	}
	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