Advertisement
shipu_a

Div 1 Problem B

Jan 15th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include<stdio.h>
  2. int fact(int n)
  3. {
  4.     int f=1;
  5.     for(int i=1;i<=n;i++)
  6.     f=f*i;
  7.     return f;
  8. }
  9.  
  10. int main()
  11. {
  12.     int test,t=0,n,i,d;
  13.     scanf("%d",&test);
  14.     while(test--)
  15.     {
  16.         scanf("%d",&n);
  17.         int odd=0,zero=0;
  18.         for(i=0;i<n;i++)
  19.         {
  20.             scanf("%d",&d);
  21.             if(d==0) zero++;
  22.             else if(d%2==1) odd++;
  23.         }
  24.         int res=odd*fact(n-1);
  25.         int sub=odd*fact(n-2);
  26.         if(zero==1)
  27.         printf("%d\n",res-sub);
  28.         else
  29.         printf("%d\n",res);
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement