| 29 | return result; |
| 30 | } |
| 31 | int main() { |
| 32 | string str1, str2; |
| 33 | cin >> str1 >> str2; |
| 34 | int count1Plus = count(str1.begin(), str1.end(), '+'); |
| 35 | int count1Minus = count(str1.begin(), str1.end(), '-'); |
| 36 | int count2Plus = count(str2.begin(), str2.end(), '+'); |
| 37 | int count2Minus = count(str2.begin(), str2.end(), '-'); |
| 38 | int count2Mark = str2.length() - (count2Plus + count2Minus); |
| 39 | if (!count2Mark) { |
| 40 | if (count2Plus == count1Plus && count2Minus == count1Minus) { |
| 41 | cout << "1.000000000000"; |
| 42 | return 0; |
| 43 | } |
| 44 | else { |
| 45 | cout << "0.000000000000"; |
| 46 | return 0; |
| 47 | } |
| 48 | } |
| 49 | int diffPlus = count1Plus - count2Plus; |
| 50 | int diffMinus = count1Minus - count2Minus; |
| 51 | if (diffPlus + diffMinus == count2Mark && diffPlus >= 0 && diffMinus >=0) { |
| 52 | long long int res = factorial(count2Mark); |
| 53 | long long int res1 = factorial(diffPlus); |
| 54 | long long int res2 = factorial(diffMinus); |
| 55 | double result = (double)res /(double) (res1 * res2); |
| 56 | long long int totalWays = pow(2, count2Mark); |
| 57 | cout << fixed; |
| 58 | cout << setprecision(12); |
| 59 | cout << result / (double)totalWays; |
| 60 | } |
| 61 | else cout << "0.000000000000"; |
| 62 | return 0; |
| 63 | } |
nothing calls this directly
no test coverage detected