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 15:00
Wanda has graduated from community university (cu) and after nine months has failed to find a job. she graduated with a degree in business, and her college was aacsb accredited. (aacsb accreditation is a specialized accreditation for business schools that evidences a quality program.) in her complaint, she alleges that four years of school and tuition should guarantee a job in the field of study and states that she wants her money back. at no time did cu guarantee job placement, either through express or implied statements. wanda does not disagree with this but still thinks that she was wronged and that it is unfair to graduate and not get a job automatically. cu will be successful in extinguishing wanda's lawsuit if its attorney files a
Answers: 2
question
Business, 22.06.2019 18:00
Martha entered into a contract with terry, an art dealer. according to the contract, terry was to supply 18 th century artifacts to martha for the play she was directing, and martha was ready to pay $50,000 for this. another director needed the same artifacts and was ready to pay $60,000. terry decided not to sell the artifacts to martha. in this case, the court may order terry to:
Answers: 2
question
Business, 22.06.2019 23:00
The quinoa seed is in high demand in wealthier countries such as the u.s. and japan. approximately 97% of all quinoa production comes from small farmers in bolivia and peru who farm at high elevations—8,000 feet or higher. the seed is considered highly nutritious. mostly grown and harvested in bolivia and peru, and sold to markets in other countries, the seed is now considered an important for these nations. the governments of bolivia and peru are hopeful that this product will increase the quality of life of their farmers.
Answers: 3
question
Business, 23.06.2019 10:30
Dan mcclure is trying to decide on how many copies of a book to purchase at the start of the upcoming selling season for his bookstore. the book retails at $28.00. the publisher sells the book to dan for $20.00. dan will dispose of all the unsold copies of the book at 75 percent off the retail price, at the end of the season. dan estimates that demand for this book during the season is normal with a mean of 100 and a standard deviation of 42. a. how many books should dan order to maximize his expected profit? b. given the order quantity in part a, what is dan's expected profit? c. the publisher's variable cost per book is $7.50. given the order quantity in part a, what is the publisher's expected profit?
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
question
Social Studies, 12.07.2019 16:40