zoj1028 Flip and Shift

  1. //http://acm.zju.edu.cn/show_problem.php?pid=1028
  2. //zoj1028 Flip and Shift

  3. //Accepted 1028 C++ 00:00.00 388K
  4. #include <stdio.h>

  5. int main()

  6. {

  7. #ifdef ONLINE_JUDGE
  8. #else
  9.        freopen("1028.txt","r",stdin);

  10. #endif

  11.        int t,i,n;

  12.        int odd,even;
           int a;

  13.        while (scanf ("%d",&t) != EOF){

  14.               while (t--){

  15.                      scanf ("%d",&n);

  16.                      odd = even = 0;

  17.                      for (i=1; i<=n; ++i){

  18.                             scanf ("%d",&a);

  19.                             if (i%2) odd += a;

  20.                             else even += a;

  21.                      }

  22.                      if (n%2) printf ("YES/n");

  23.                      else if ((odd-even)<=1 && (odd-even)>=-1) printf ("YES/n");

  24.                      else printf ("NO/n");

  25.               }

  26.        }

  27. #ifdef ONLINE_JUDGE
  28. #else
  29.        fclose(stdin);

  30. #endif

  31.        return 0;

  32. }
阅读更多
文章标签: c
个人分类: ZOJ
相关热词: zoj1028
下一篇zoj1002 Fire Net
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭