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

Other questions on the subject: Business

image
Business, 21.06.2019 21:00, erikstein8298
Exercise 8-6 goods in transit [lo8-2] the kwok company's inventory balance on december 31, 2016, was $190,000 (based on a 12/31/16 physical count) before considering the following transactions: 1. goods shipped to kwok f. o.b. destination on december 20, 2016, were received on january 4, 2017. the invoice cost was $35,000. 2. goods shipped to kwok f. o.b. shipping point on december 28, 2016, were received on january 5, 2017. the invoice cost was $22,000. 3. goods shipped from kwok to a customer f. o.b. destination on december 27, 2016, were received by the customer on january 3, 2017. the sales price was $45,000 and the merchandise cost $27,000. 4. goods shipped from kwok to a customer f. o.b. destination on december 26, 2016, were received by the customer on december 30, 2016. the sales price was $25,000 and the merchandise cost $18,000. 5. goods shipped from kwok to a customer f. o.b. shipping point on december 28, 2016, were received by the customer on january 4, 2017. the sales price was $30,000 and the merchandise cost $17,000. required: determine the correct inventory amount to be reported in kwok's 2016 balance sheet.
Answers: 1
image
Business, 22.06.2019 00:00, helpmeplease95
Pettijohn inc. the balance sheet and income statement shown below are for pettijohn inc. note that the firm has no amortization charges, it does not lease any assets, none of its debt must be retired during the next 5 years, and the notes payable will be rolled over. balance sheet (millions of $) assets 2016 cash and securities $ 1,554.0 accounts receivable 9,660.0 inventories 13,440.0 total current assets $24,654.0 net plant and equipment 17,346.0 total assets $42,000.0 liabilities and equity accounts payable $ 7,980.0 notes payable 5,880.0 accruals 4,620.0 total current liabilities $18,480.0 long-term bonds 10,920.0 total debt $29,400.0 common stock 3,360.0 retained earnings 9,240.0 total common equity $12,600.0 total liabilities and equity $42,000.0 income statement (millions of $) 2016 net sales $58,800.0 operating costs except depr'n $54,978.0 depreciation $ 1,029.0 earnings bef int and taxes (ebit) $ 2,793.0 less interest 1,050.0 earnings before taxes (ebt) $ 1,743.0 taxes $ 610.1 net income $ 1,133.0 other data: shares outstanding (millions) 175.00 common dividends $ 509.83 int rate on notes payable 1. what is the firm's current ratio? (points : 6) 0.97 1.08 1.20 1.33 2. what is the firm's quick ratio? (points : 6) 0.49 0.61 0.73 0.87 3. what is the firm's total assets turnover? (points : 6) 0.90 1.12 1.40 1.68 4. what is the firm's inventory turnover ratio? (points : 6) 4.38 4.59 4.82 5.06 5. what is the firm's debt ratio? (points : 6) 45.93% 51.03% 56.70% 70.00% 6. what is the firm's roa? (points : 6) 2.70% 2.97% 3.26% 3.59% 7. what is the firm's roe? (points : 6) 8.54% 8.99% 9.44% 9.91%
Answers: 2
image
Business, 22.06.2019 09:00, Moocow17
Almost 80% of business owners are clueless about the competition, resulting in a) lost market share and customers. b) needless lawsuits. c) uninspired products. d) lack of perseverance
Answers: 2
image
Business, 22.06.2019 15:10, emilypzamora11
On december 31, 2013, coronado company issues 173,000 stock-appreciation rights to its officers entitling them to receive cash for the difference between the market price of its stock and a pre-established price of $10. the fair value of the sars is estimated to be $5 per sar on december 31, 2014; $2 on december 31, 2015; $10 on december 31, 2016; and $8 on december 31, 2017. the service period is 4 years, and the exercise period is 7 years. prepare a schedule that shows the amount of compensation expense allocable to each year affected by the stock-appreciation rights plan.
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 in other subjects:

Konu
Mathematics, 20.03.2020 02:43