<\/span><\/h2>\n\n\n\nThe ratio of boys to girls for babies born in Russia is 1.09 : 1<\/strong>. If there is 1<\/strong> child born per birth, what proportion of Russian families with exactly 6<\/strong> children will have at least 3<\/strong> boys?<\/p>\n\n\n\nWrite a program to compute the answer using the above parameters. Then print your result, rounded to a scale of 3<\/strong> decimal places (i.e., 1.234<\/strong> format).<\/p>\n\n\n\n<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nA single line containing the following values:<\/p>\n\n\n\n
1.09 1<\/code><\/pre>\n\n\n\nIf you do not wish to read this information from stdin, you can hard-code it into your program.<\/p>\n\n\n\n
<\/span>Output Format<\/strong><\/span><\/h2>\n\n\n\nPrint a single line denoting the answer, rounded to a scale of 3<\/strong> decimal places (i.e., 1.234<\/strong> format).<\/p>\n\n\n\n<\/span>Solution – Day 4: Binomial Distribution I <\/strong><\/span><\/h2>\n\n\n\n<\/span>C++<\/strong><\/span><\/h3>\n\n\n\n#include <cmath>\n#include <cstdio>\n#include <vector>\n#include <iostream>\n#include <algorithm>\nusing namespace std;\n\n\ndouble b = 1.09, g = 1; \/\/ given\n\nint fact(int n)\n{\n if(n<2) return 1;\n return n*fact(n-1);\n}\n\ndouble nCr(int n, int r)\n{\n return fact(n)\/(fact(r)*fact(n-r));\n}\n\nint main() {\n \/* Enter your code here. Read input from STDIN. Print output to STDOUT *\/ \n \n double p = b\/(b+g);\n double q = 1 - p;\n \n double prob = 0.0;\n \n for(auto i=6; i>=3; i--)\n {\n prob += nCr(6, i)*pow(p, i)*pow(q, 6-i);\n }\n printf(\"%0.3f\\n\", prob);\n \n return 0;\n}\n\n<\/pre>\n\n\n\n