Number of positive integral solutions
Basic Accuracy: 28.08% Submissions: 592 Points: 1

You are given an equation of the form x1+x2+...+xN=K. You need to find the total number of positive integral solutions of this equation.

Input:
The first line of the input contains an integer T, denoting the number of test cases. Then T test case follows. Each testcase contains a single line that denotes the equation.

Output:
Print the total number of positive integral solutions.

Constraints:
1 <= T <= 100
1 <= K <= 25
2 <= N <= 10

Example:

Input:
4
a+b=5
a+b=1
a+b+c=10
a+b+c+d+e=15

Output:
4
0
36
1001

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.