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,就帮助!下面是我的代码!#include<iostream> #include<stdlib.h> using namespace std; int main() { int n,*p,i; int s=0; int num=0; while(cin>>n&&n) { ++s; p=(int *)calloc(n,sizeof(int)); int sum=0; for(i=0;i<n;++i) { cin>>p[i]; sum+=p[i]; } sum/=n; for(i=0;i<n;++i) { if(p[i]>sum) num+=p[i]-sum; } } cout<<"Set #"<<s<<endl; cout<<"The minimum number of moves is "<<num<<"."<<endl; cout<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator