Arrange Balls
Submissions: 469   Accuracy:

51.4%

  Difficulty: Easy   Marks: 2

There are ‘p’ balls of type P, ‘q’ balls of type Q and ‘r’ balls of type R. Using the balls we want to create a straight line such that no two balls of same type are adjacent.

Input:
First line of input contains number of test cases T. Each line of test case contains number of balls of each type seperated by a single space.

Output:
Number of ways to arrange balls are displayed and 0 is displayed if there are no ways.

Constraints:
1 <= T <= 30
1 <= p,q,r <= 9

Example:

Input:
2
2 2 2
1 1 1

Output:
30
6

** For More Input/Output Examples Use 'Expected Output' option **

Author: atharv


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.