📄 1370.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 1370 on 2005-03-23 at 15:30:03 */
#include <stdio.h>
int main()
{
int total, average, candy[100000], n, step;
int i;
while(scanf("%d", &n) == 1){
if(n == -1){
return 0;
}else{
total = 0;
for(i = 0; i < n; i++){
scanf("%d", &candy[i]);
total += candy[i];
}
if(total % n != 0){
printf("-1\n");
}else{
average = total / n;
step = 0;
for(i = 0; i < n; i++){
if(candy[i] < average){
step += (average - candy[i]);
}
}
printf("%d\n", step);
}
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -