P21763 [GeeksforGeeks] Number of positive integral solutions2115
普及
题目描述

You are given an equation of the form x_{1}+x_{2}+...+x_{N}=K. You need to find the total number of positive integral solutions of this equation.

Example 1:
Input: s = a+b=5
Output: 4
Explanation: (4,1) , (1,4) , (2,3) , (3,2)
Example 2:
Input: s = a+b=1
Output: 0
Explanation: No solution exist.

Your Task:
You don't need to read input or print anything. Your task is to complete the function posIntSol() which takes a string as input and returns number of solutions.
Note: Distance has to be calculated with a precision of 0.0000000000001
Expected Time Complexity : O(Length of given string)
Expected Auxiliary Space : O(1)

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

输入格式

见题面

输出格式

见题面

样例输入
s = a+b=5
样例输出
4