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 16:00
Winners of the georgia lotto drawing are given the choice of receiving the winning amount divided equally over 2121 years or as a lump-sum cash option amount. the cash option amount is determined by discounting the annual winning payment at 88% over 2121 years. this week the lottery is worth $1616 million to a single winner. what would the cash option payout be?
Answers: 3
question
Business, 22.06.2019 22:40
Effective capacity is the: a. capacity a firm expects to achieve given the current operating constraints.b. minimum usable capacity of a particular facility.c. sum of all the organization's inputs.d. average output that can be achieved under ideal conditions.e. maximum output of a system in a given period.
Answers: 1
question
Business, 23.06.2019 00:10
Mno corporation uses a job-order costing system with a predetermined overhead rate based on direct labor-hours. the company based its predetermined overhead rate for the current year on the following data: total estimated direct labor-hours 50,000 total estimated fixed manufacturing overhead cost $ 285,000 estimated variable manufacturing overhead per direct labor-hour $ 3.80 recently, job p123 was completed with the following characteristics: total actual direct labor-hours 20 direct materials $ 710 direct labor cost $ 500 the amount of overhead applied to job p123 is closest to:
Answers: 2
question
Business, 23.06.2019 10:00
Avillage levied property taxes of $910,000 for calendar year 2019 on january 1, 2019 and immediately set up an allowance of $10,000 for uncollectible taxes. the village collected $870,000 in cash during 2019. it expected to collect $22,000 of the unpaid taxes during the first 60 days of 2020 and an additional $8,000 during the rest of 2020. how much should the village recognize as property tax revenues in its 2019 general fund financial statements? a) $870,000 b) $892,000 c) $900,000 d) $910,000
Answers: 1
You know the right answer?
Vyasa has to complete a programming assignment overnight. He has to write n lines of code before mor...
Questions
Questions on the website: 13722367