Home | Problems | Discuss | Login

  

为什么总是wa?

1005: Move cards

987456321 | 2019-08-04 15:24:55 | delete | edit
打印结果记得要换行哦(我就是因为这个WA5次,最后改过来就过了 
43041139 | 2011-04-26 20:36:37 | delete | edit
这是我刚刚做的,可以参考一下:

#include<iostream>
using namespace std;

int main(int argc, char *argv[])
{
    int times;
    cin>>times;
    for(int j = 0; j<times; j++)
    {
            int num;
            long long average = 0;
            cin>>num;
            long long *a = new long long[num];
            for(int j = 0; j<num; j++)
            {
                 cin>>a[j];
                 average += a[j];        
            }
            average = average/num;
            int step = 0;
            for(int j = 0; j<num; j++)
            {
                 a[j] -= average;        
            }
            for(int j = 0; j<num-1; j++)
            {
                 if(a[j]!=0)
                 {
                      a[j+1] += a[j];
                      step++;           
                 }        
            }
            cout<<step<<endl;
            delete []a;
    }     
    //system("PAUSE");
    return 0;
}
 
Johnson-Liu | 2007-11-06 16:53:27 | delete | edit
人都快疯了,测了那么多都是对的,提上去就是wa!!!!!!!!!!!!
简直是打击人的自信心哦 

Please login to reply.