Arrange Balls
Easy Accuracy: 50.08% Submissions: 641 Points: 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

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.