| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
讨论中的问题都注意了,但还是WA。大侠们帮我看看吧,为什么WA#include <iostream>
#include <vector>
using namespace std;
int process(vector<int> &input)
{
int averageHeight=0, totalHeight=0;
//算平均值
for ( int i=1; i<input.size(); i++ )
{
totalHeight += input[i];
}
averageHeight = totalHeight/input[0];
int counter = 0;
for ( int i=1; i<input.size(); i++ )
{
if ( (input[i]-averageHeight) > 0 )
{
counter += input[i]-averageHeight;
}
}
return counter;
}
int main()
{
int a;
vector<int> input;
int caseNo=1;
while ( cin>>a )
{
if ( a!=0 )
{
input.push_back(a);
}
else
{
cout<<"Set #"<<caseNo<<endl<<"The minimum number of moves is "<<process( input )<<"."<<endl<<endl;
caseNo++;
input.clear();
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator