রবিবার, ২৮ আগস্ট, ২০১৬

UVA 591 - Box of Bricks

///...................SUBHASHIS MOLLICK....................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///.....................SESSION-(14-15)....................///
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<ctype.h>
#include<bits/stdc++.h>
using namespace std;
main()
{
long int n,count=1;
while(scanf("%ld",&n)!=EOF)
{
long j,total=0,rslt,rslt1=0,rslt2=0,k,a[10000]={0};
if(n==0)
break;
else
{
for(j=0;j<n;j++)
{
scanf("%ld",&a[j]);
total=total+a[j];
}
rslt=total/n;
for(k=0;k<n;k++)
{
if(a[k]>rslt)
{
rslt2=rslt2+(a[k]-rslt);
}
}
}
printf("Set #%ld\nThe minimum number of moves is %ld.\n\n",count,rslt2);
count++;
}
}


কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন

Factory Pattern

Factory Method  is a creational design pattern that provides an interface for creating objects in a superclass but allows subclasses to alte...