There is a lottery with n coupons and n people take part in it. Each person...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
There is a lottery with n coupons and n people take part in it. Each person picks exactly one coupon. Coupons are numbered consecutively from 1 to n, n being the maximum ticket number. The winner of the lottery is any person who owns a coupon where the sum of the digits on the coupon is equal to s. If there are multiple winners, the prize is split equally among them. Determine how many values of s there are where there is at least one winner and the prize is split among most people. Example n = 12 The list of coupon numbers generated from 1 to n is [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]. The sums of the digits are [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]. The largest number of winners is 2 which will occur for coupons numbered [1, 10], [2, 11] and [3, 12]. The maximum number of possible winners occurs for any of these 3 possible values of s, so 3 is the answer. Function Description Complete the function lotteryCoupons in the editor below. The function must return the number of ways to choose s in such a way that there is at least one winner and the prize is split among the greatest number of people. lotteryCoupons has the following parameter(s): n: an integer that represents the maximum coupon number Constraints • 1 ≤ n ≤ 104 Input Format For Custom Testing Sample Case 0 Sample Input STDIN ‒‒‒‒‒ 3 Function w ‒‒‒‒‒‒ → n = 3 Sample Output There is a lottery with n coupons and n people take part in it. Each person picks exactly one coupon. Coupons are numbered consecutively from 1 to n, n being the maximum ticket number. The winner of the lottery is any person who owns a coupon where the sum of the digits on the coupon is equal to s. If there are multiple winners, the prize is split equally among them. Determine how many values of s there are where there is at least one winner and the prize is split among most people. Example n = 12 The list of coupon numbers generated from 1 to n is [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]. The sums of the digits are [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]. The largest number of winners is 2 which will occur for coupons numbered [1, 10], [2, 11] and [3, 12]. The maximum number of possible winners occurs for any of these 3 possible values of s, so 3 is the answer. Function Description Complete the function lotteryCoupons in the editor below. The function must return the number of ways to choose s in such a way that there is at least one winner and the prize is split among the greatest number of people. lotteryCoupons has the following parameter(s): n: an integer that represents the maximum coupon number Constraints • 1 ≤ n ≤ 104 Input Format For Custom Testing Sample Case 0 Sample Input STDIN ‒‒‒‒‒ 3 Function w ‒‒‒‒‒‒ → n = 3 Sample Output
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Allergan is a major pharmaceutical firm. You work for Allergan's CFO and are evaluating a major and expensive drug trial. The drug trial would require an investment of $95 million today If the trial...
-
Determine CPI, ETC (1), and EAC. Activity Total PV 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 6 6 2 20 10 10 3 30 9 6 6 6 3 4 20 8 2 5 5 5 16 4 4 4 4 6 18 9 9 7 8 4 4 Status Report: Ending Period 5 Task %...
-
(1) Given A and i. (1a) Find the equivalent amount at the end of year 1. (1b) Find the equilvalent amount at the end of year B. (2) Given X and i, Find the annual equivalent A from year S to 8. *...
-
GoFast Corp. wishes to renovate the property so that he can sell it at a higher price.The after-tax cash flow over next year up to RM320,000 if the property was renovated.The renovation cost is...
-
Opening in to larynx?
-
Describe the Internet and how Web 3.0 and 4.0 provide greater opportunities for marketers to interact with their customers.
-
Refer to the information in Exercise 24-3 and assume instead that double-declining depreciation is applied. Compute the machines payback period (ignore taxes). (Round the payback period to three...
-
Emergency calls to Winter Park, Floridas 911 systems for the past 24 weeks are as follows: (a) Compute the exponentially smoothed forecast of calls for each week. Assume an initial forecast of 50...
-
8. *A 2-kg block of copper is heated to 400 C and dropped into an insulated bucket that contains a mixture of ice and water at 0 C. The final temperature of the copper is 0 C. How much ice melted in...
-
Compute FUTA & SUTA Tax: Payroll: $737,910.00 Wages in Excess of $7,000 Cap $472,120.00 SUTA Rate 2.90% Gross FUTA Rate FUTA Credit Rate Maximum Credit Allowed Compute taxes considering FUTA...
-
A list of the accounts of Medford Corporation is given below, followed by some selected transactions. Indicate the accounts that should be debited and credited for the transaction or adjusting entry...
-
You find a stock priced at $35 that is expected to pay a dividend of $1.50 next year. If you also expect the price to be $37 next year, what is the expected return on the stock?
-
Within Year, Inc. has bonds outstanding with a $1,000 par value and a maturity of 18 years. The bonds have an annual coupon rate of 17.0% with semi-annual coupon payments. You would expect a quoted...
-
A callable bond is a bond that can be redeemed before its maturity date. This basically means that the issuer can call the bond at a predetermined call date if they chose to. If interest rates...
-
Current target capital structure is 15% debt, 2% preferred stock and 83% common equity. If changed to 50% equity and 50% debt (by issuing additional debt, and using proceeds to buy back 33% equity...
-
The HSBC stock price is currently trading at $200. You believe that HSBC will have an expected return of 8% with volatility of 24.1% per year, while annual interest rates with annual compounding are...
-
Chris Corporation acquired 75% of Martin Company's ownership on January 1, 20X8, for $96,000. At that date, the fair value of the noncontrolling interest was $32,000. The book value of Martin's net...
-
Burberrys competitive advantage is through its differentiation strategy. What risk should Burberry remain aware of?
-
Two balls are chosen randomly from an urn containing 8 white, 4 black, and 2 orange balls. Suppose that we win $2 for each black ball selected and we lose $1 for each white ball selected. Let X...
-
Consider the following dice game: A pair of dice is rolled. If the sum is 7, then the game ends and you win 0. If the sum is not 7, then you have the option of either stopping the game and receiving...
-
The lifetimes of batteries are independent exponential random variables, each having parameter . A flashlight needs 2 batteries to work. If one has a flashlight and a stockpile of n batteries, what...
-
Study, along the lines of Section 3.8, the statistical mechanics of a system of \(N\) "Fermi oscillators," which are characterized by only two eigenvalues, namely 0 and \(\varepsilon\).
-
The energy levels of a quantum-mechanical, one-dimensional, anharmonic oscillator may be approximated as \[ \varepsilon_{n}=\left(n+\frac{1}{2}ight) \hbar \omega-x\left(n+\frac{1}{2}ight)^{2} \hbar...
-
Oxygen is a paramagnetic gas obeying Langevin's theory of paramagnetism. Its susceptibility per unit volume, at \(293 \mathrm{~K}\) and at atmospheric pressure, is \(1.80 \times 10^{-6}...
Study smarter with the SolutionInn App