591

一个破水题,WA了好几次,发现竟然是因为没看见每个test之后要输出个空行。。。

//============================================================================
// Name        : 591.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

int a[100];
int n, t, sum, T;

int main() {
	freopen("a.txt", "r", stdin);
	T = 0;
	while(scanf("%d", &n)&&n){
		T++;
		printf("Set #%d\n", T);
		sum = 0;
		for(int i = 1;i <= n;i++){
			scanf("%d", &a[i]);
			sum += a[i];
		}
		sum /= n;
		t = 0;
		for(int i = 1;i <= n;i++){
			if(a[i] > sum){
				t += a[i]-sum;
			}
		}
		printf("The minimum number of moves is %d.\n\n", t);
	}
	return 0;
}

posted @ 2011-06-18 00:09  KOKO's  阅读(141)  评论(0编辑  收藏  举报