Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int fact(int n)
- {
- int f=1;
- for(int i=1;i<=n;i++)
- f=f*i;
- return f;
- }
- int main()
- {
- int test,t=0,n,i,d;
- scanf("%d",&test);
- while(test--)
- {
- scanf("%d",&n);
- int odd=0,zero=0;
- for(i=0;i<n;i++)
- {
- scanf("%d",&d);
- if(d==0) zero++;
- else if(d%2==1) odd++;
- }
- int res=odd*fact(n-1);
- int sub=odd*fact(n-2);
- if(zero==1)
- printf("%d\n",res-sub);
- else
- printf("%d\n",res);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement