Box of Bricks

原创 2013年12月04日 15:07:26
#include<stdio.h>
int main()
{
    int M, num, m, j=1;
    int a[51];
    int i, avg;
    while((scanf("%d", &M)!= EOF) && M)
    {
        num = 0;
        m = 0;
        for(i=0; i<M; i++){
            scanf("%d", &a[i]);
            m += a[i];
        }
        avg = m/M;
        for(i=0; i<M; i++){
            if(a[i] > avg)
                num += (a[i] - avg);
        }
        printf("Set #%d\n", j++);
        printf("The minimum number of moves is %d.\n\n", num);
    }
    return 0;
}

题目的实质就是计算平均值,然后把各个数与平均值比较,比平均值大的都要移给比平均值小的。

HDU 2088 Box of Bricks

Box of Bricks Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

HDU 1.2.2 Box of Bricks

Box of Bricks Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others...

水题 Box of Bricks

Box of Bricks Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe...

HDU 1326 Box of Bricks

平均值,整型计算

uva 591 Box of Bricks

uva 591 Box of Bricks 题目大意:把n堆砖移成相同高度需要移动多少块砖。 解题思路:先求平均值,再用比平均值大的数减去平均值, 所有差的和就是所求值。 #include ...

HDU1326:Box of Bricks

Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon an...

AOJ-AHU-OJ-12 Box of Bricks

Box of Bricks Time Limit: 1000 ms   Case Time Limit: 1000 ms   Memory Limit: 64 MB   Description Lit...

UVA 591 Box of Bricks

Box of Bricks  Little Bob likes playing with his box of bricks. He puts the bricks one ...

591 - Box of Bricks

Box of Bricks  Little Bob likes playing with his box of bricks. He puts the bricks one upon anoth...
  • SIOFive
  • SIOFive
  • 2013年07月21日 18:32
  • 734

水题 ~ HDU 1326 Box of Bricks

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submissio...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Box of Bricks
举报原因:
原因补充:

(最多只允许输入30个字)