码迷,mamicode.com
首页 > 其他好文 > 详细

zju 1251 Bricks box 砖盒----------hdu 1326

时间:2014-08-02 01:31:52      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   for   2014   

bubuko.com,布布扣bubuko.com,布布扣

 

 

bubuko.com,布布扣
#include <iostream>
using namespace std;
int main()
{
    int a[51],n,k=1;
    while(cin>>n,n)
    {
        int i,ans=0,s=0;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            s+=a[i];
        }
        s/=n;
        for(i=0;i<n;i++)
            if(a[i]>s)ans+=a[i]-s;
        cout<<"Set #"<<k++<<endl;
        cout<<"The minimum number of moves is "<<ans<<.<<endl<<endl;    
    }
    return 0;
}
View Code

 

#include <iostream>
using namespace std;
int main()
{
int a[51],n,k=1;
while(cin>>n,n)
{
int i,ans=0,s=0;
for(i=0;i<n;i++)
{
cin>>a[i];
s+=a[i];
}
s/=n;
for(i=0;i<n;i++)
if(a[i]>s)ans+=a[i]-s;
cout<<"Set #"<<k++<<endl;
cout<<"The minimum number of moves is "<<ans<<‘.‘<<endl<<endl;
}
return 0;
}

zju 1251 Bricks box 砖盒----------hdu 1326,布布扣,bubuko.com

zju 1251 Bricks box 砖盒----------hdu 1326

标签:style   blog   http   color   os   io   for   2014   

原文地址:http://www.cnblogs.com/2014acm/p/3885951.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!