PersonalCorpus 版 (精华区)

Your C++ program has solved Ok the problem 591 (Box of Bricks)
in 0.010 seconds with low memory spent.


void main()
{
    int i,j,k,n,t=0;
    int a[50];

    while(1) {
        scanf("%d\n",&n); if (n==0) break;
        printf("Set #%d\n",++t);
        k=0; for (i=0;i<n;i++) { scanf("%d",&a[i]); k+=a[i]; }
        k/=n; j=0; for (i=0;i<n;i++) j+=abs(k-a[i]);
        printf("The minimum number of moves is %d.\n\n",j/2);
    }
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:1.953毫秒