UVa 591 Box of Bricks
zz...輕鬆簡單的小題
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* UVa 591 | |
* Author: chchwy | |
* Last Modified: 2009.11.19 | |
*/ | |
#include<cstdio> | |
int main() | |
{ | |
int numCase = 1; | |
int numWall = 0; | |
while (scanf("%d", &numWall) == 1) | |
{ | |
if (numWall == 0) break; | |
int wall[64]; | |
int sum = 0; | |
for (int i = 0; i < numWall; ++i) | |
{ | |
scanf("%d", wall + i); | |
sum += wall[i]; | |
} | |
int avg = sum / numWall; | |
int move = 0; | |
for (int i = 0; i < numWall; ++i) | |
if (wall[i] > avg) | |
move += wall[i] - avg; | |
printf("Set #%d\n", numCase++); | |
printf("The minimum number of moves is %d.\n\n", move); | |
} | |
} |
hello,
回覆刪除I'm also solving the UVa 591,
can you check what's the problem of my idea
http://ideone.com/eY9w3
it always shows "Wrong Answer"
thank you