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
Answers: 1
Business, 22.06.2019 11:50, Attaullah2519
Christopher kim, cfa, is a banker with batts brothers, an investment banking firm. kim follows the energy industry and has frequent contact with industry executives. kim is contacted by the ceo of a large oil and gas corporation who wants batts brothers to underwrite a secondary offering of the company's stock. the ceo offers kim the opportunity to fly on his private jet to his ranch in texas for an exotic game hunting expedition if kim's firm can complete the underwriting within 90 days. according to cfa institute standards of conduct, kim: a) may accept the offer as long as he discloses the offer to batts brothers. b) may not accept the offer because it is considered lavish entertainment. c) must obtain written consent from batts brothers before accepting the offer.
Answers: 1
Business, 22.06.2019 23:40, jaycobgarciavis
John has been working as a tutor for $300 a semester. when the university raises the price it pays tutors to $400, jasmine enters the market and begins tutoring as well. how much does producer surplus rise as a result of this price increase?
Answers: 1
Business, 24.06.2019 02:00, Yomarie1104
Glueck and glueck have identified a number of personality traits that characterize antisocial youth. which is one of these traits?
Answers: 1
Vyasa has to complete a programming assignment overnight. He has to write n lines of code before mor...
Mathematics, 02.07.2020 07:01
Mathematics, 02.07.2020 07:01
English, 02.07.2020 07:01
Mathematics, 02.07.2020 07:01
Mathematics, 02.07.2020 07:01
Mathematics, 02.07.2020 07:01
Mathematics, 02.07.2020 07:01
Mathematics, 02.07.2020 07:01