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, 21.06.2019 21:00
Colah company purchased $1.8 million of jackson, inc. 8% bonds at par on july 1, 2018, with interest paid semi-annually. when the bonds were acquired colah decided to elect the fair value option for accounting for its investment. at december 31, 2018, the jackson bonds had a fair value of $2.08 million. colah sold the jackson bonds on july 1, 2019 for $1,620,000. the purchase of the jackson bonds on july 1. interest revenue for the last half of 2018. any year-end 2018 adjusting entries. interest revenue for the first half of 2019. any entry or entries necessary upon sale of the jackson bonds on july 1, 2019. required: 1. prepare colah's journal entries for above transaction.
Answers: 1
question
Business, 21.06.2019 22:10
There are more than two types of bachelors’ degrees true or false?
Answers: 1
question
Business, 22.06.2019 07:50
The questions of economics address which of the following ? check all that apply
Answers: 3
question
Business, 22.06.2019 11:10
An insurance company estimates the probability of an earthquake in the next year to be 0.0015. the average damage done to a house by an earthquake it estimates to be $90,000. if the company offers earthquake insurance for $150, what is company`s expected value of the policy? hint: think, is it profitable for the insurance company or not? will they gain (positive expected value) or lose (negative expected value)? if the expected value is negative, remember to show "-" sign. no "+" sign needed for the positive expected value
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
Health, 31.03.2020 23:30
question
Social Studies, 31.03.2020 23:30
Questions on the website: 13722360