subject
Business, 15.07.2020 04:01 dassiekeaton

Vyasa has to complete a programming assignment overnight. He has to write n lines of code before morning. He is dead tired and he tries drinking some black coffee to keep him awake. But each time he drinks a cup of coffee he stays awake for a short amount of time but his productivity goes down by a constant factor k This is how he plans to write the program. He will write the first v lines of code, then drink his first cup of coffee. Since his productivity has gone down by a factor of k he will write v // k lines of code. He will have another cup of coffee and then write v // k**2 lines of code. He will have another cup of coffee and write v // k**3 lines of code and so on. He will collapse and fall asleep when v // k ** p becomes 0.
Now Vyasa does want to complete his assignment and maximize on his sleep. So he wants to figure out the minimum allowable value of v for a given productivity factor that will allow him to write at least n lines of code before he falls asleep.
Your input file will be called work. txt. Here is a typical file:
2300 2
59 9
The first line is T the number of test cases. This will be followed by T lines of input. Each line of input will have two numbers n and k. n is the number of lines of code to write and k is the productivity factor, where 1 ≤ n ≤ 106 and 2 ≤ k ≤ 10.
For each test case your output to the screen will be v lines of code the Vyasa has to write, as well as the time it took for each function. For the above two test cases, the output will be:
Binary Search: 152
Time: 9.512901306152344e-05
Linear Search: 152
Time: 0.0005910396575927734
Binary Search: 54
Time: 4.696846008300781e-05
Linear Search: 54
Time: 9.012222290039062e-05
Do not worry if your times don't match exactly. For this assignment, main has been written completely for you, and nothing needs to be changed in it.
You will be solving this problem in 2 ways. First, you will write a function that uses a linearsearch to solve the problem. Then you will write a function that uses a modified binary search algorithm to solve it again

ansver
Answers: 1

Another question on Business

question
Business, 22.06.2019 02:00
Ida sidha karya company is a family-owned company located on the island of bali in indonesia. the company produces a handcrafted balinese musical instrument called a gamelan that is similar to a xylophone. the gamelans are sold for $860. selected data for the company’s operations last year follow: units in beginning inventory 0 units produced 320 units sold 285 units in ending inventory 35 variable costs per unit: direct materials $ 135 direct labor $ 355 variable manufacturing overhead $ 30 variable selling and administrative $ 15 fixed costs: fixed manufacturing overhead $ 64,000 fixed selling and administrative $ 27,000 the absorption costing income statement prepared by the company’s accountant for last year appears below: sales $ 245,100 cost of goods sold 205,200 gross margin 39,900 selling and administrative expense 31,275 net operating income $ 8,625 required: 1. under absorption costing, how much fixed manufacturing overhead cost is included in the company's inventory at the end of last year? 2. prepare an income statement for last year using variable costing. what is the amount of the difference in net operating income between the two costing methods?
Answers: 1
question
Business, 22.06.2019 11:30
(select all that apply) examples of email use that could be considered unethical include denying receiving an e-mail requesting that you work late forwarding a chain letter asking for donations to a good cause sending a quick message to your friend about last weekend sending your boss the monthly sales figures in an attachment setting up a meeting with your co-worker sharing a funny joke with other employees
Answers: 2
question
Business, 22.06.2019 11:50
Select the correct answer. ramon applied to the state university in the city where he lives, but he was denied admission. what should he do now? a.change his mind about graduating and drop out of high school so he can start working right away. b. decide not to go to college, because he didn’t have a backup plan. c.stay positive and write a mean letter to let the college know that they made a bad decision. d. learn from this opportunity, reevaluate his options, and apply to his second and third choices.
Answers: 2
question
Business, 22.06.2019 19:00
Andy purchases only two goods, apples (a) and kumquats (k). he has an income of $125 and can buy apples at $5 per pound and kumquats at $5 per pound. his utility function is u(a, k) = 6a + 2k. what is his marginal utility for apples and his marginal utility for kumquats? andy's marginal utility for apples (mu subscript a) is mu subscript aequals 6 and his marginal utility for kumquats (mu subscript k) is
Answers: 2
You know the right answer?
Vyasa has to complete a programming assignment overnight. He has to write n lines of code before mor...
Questions
question
Mathematics, 17.07.2019 23:30
question
Mathematics, 17.07.2019 23:30
question
Biology, 17.07.2019 23:30
question
Mathematics, 17.07.2019 23:30
Questions on the website: 13722367