5 Paint Ceiling Want Build House Building Company Hired Build Houses Sides Specific Set S Q43901799


In c++ please
5. Paint the ceiling You want to build yourself a house. The building company you hired can only build houses with sides from their specific set s. That means they can build you a square house or a rectangular one but if and only if its length and width belong to the set s. This month, they have a special promotion: they will paint the ceiling of a new house for free…but only if its area is not more than a. You want them to do it for free but you also want to be sure that the house will be comfortable and not too small. How many possible house configurations can you create to have the ceiling painted for free given the side lengths offered? There is a method to how the company decides what lengths of sides to produce. To determine n lengths of wall segments to offer, they start with a seed value s0, some variables k, b and m, and use the following equation to determine all other side lengths s[i]: s[i]=((k*s[i-1]+b) mod m)+1+s[i-1]) for 1 si<n For example, you are given s[0] = s0 = 2 and they will produce n = 3 total wall lengths. If k = 3, b = 3 and m = 2 we have: calculation result ((3*2+3)%2)+1+2 4 ((3*4+3)%2)+1+4 6 [2] [2,4] [2,4,6] Now that we have our set of lengths, we can brute force the solution using the following tests assuming a = 15: s = [2, 4, 6] sl s2 sl*s2 <= a sl*s2 4 True 2 True 4 12 True True 4 8 False 4 4 16 False 24 12 True False 24 False 36 There are 5 combinations that will result in a free paint job. Brute force will not meet the time constraints on large sets. Function Description Complete the function variantsCount in the editor below. The function must return an integer that denotes the number of variants that allow you to use the promotion. variantsCount has the following parameter(s): n: an integer, the number of wall lengths offered s0: an integer, the length of the shortest wall k, b, m: three arbitrary integers a: a long integer, the largest area that will be painted for free Constraints • 1sns6*107 • 1 s sli)s 10°, 0si<n • 1sk, b, m s 10° • 1sas 1018 • Input Format for Custom Testing v Sample Case 0 Sample Input 4 Sample Output Show transcribed image text 5. Paint the ceiling You want to build yourself a house. The building company you hired can only build houses with sides from their specific set s. That means they can build you a square house or a rectangular one but if and only if its length and width belong to the set s. This month, they have a special promotion: they will paint the ceiling of a new house for free…but only if its area is not more than a. You want them to do it for free but you also want to be sure that the house will be comfortable and not too small. How many possible house configurations can you create to have the ceiling painted for free given the side lengths offered? There is a method to how the company decides what lengths of sides to produce. To determine n lengths of wall segments to offer, they start with a seed value s0, some variables k, b and m, and use the following equation to determine all other side lengths s[i]: s[i]=((k*s[i-1]+b) mod m)+1+s[i-1]) for 1 si
Expert Answer
Answer to 5. Paint the ceiling You want to build yourself a house. The building company you hired can only build houses with sides…
OR