Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve in c + + There are three integers, x , y , and k , and a given integer n . Initially, x and

solve in c++
There are three integers, x,y, and k, and a given integer n. Initially, x and y are zero, and k is a fixed arbitrary constant.
Perform the following operation that consists of two steps in sequence until n becomes zero.
Decrease n by k, and increase x by k. If n is less than k, then x is increased by n and n becomes zero
Decrease n by 20% ofts value and add the same to y. If 20% of n is not an integer, then take the greatest integer less than or equal to it, i.e. its floor. Example: 0.99 becomes 0,1.2 becomes 1.
Find the minimum value of k such that xy)(1 after the above operations are finished on the given integer n.
Example:
n=100
Given n=100, Initially we have x=0,y=0. It is optimal to choose k=7,
n=75,x=7,y=18(x is increased by 7,n is decreased by 7,n=93,y is increased by 20% of ni.e 20% of 93=18.6,y=18,n=
SmExample:n=100Given n =100, Initially we have x=0y=0. Itis optimal to choose k=7,1. n=75, X=7, y=18(x is increased by 7, nisdecreased by 7, n =93, y is increased by20% of ni.e 20% of 93=18.6, y=18, n=75)2. n =55, X =14, y=313. n=39, x =21, y=404. n=26, x =28, y=465. n=16, X=35, y=49(x is increased by 7, nis decreased by 7, n=19, yis increased by20% of ni.e 20% of 19=3.8, y is increasedby 3, n is decreased by 3, n=16)6. n=8,X =42, y =507. n=1, X =49, y =508. n =0, x =50. y=50(as n=1, which is lesSthat k, xis increased by n ie 1, nisreduced to 0)Hence the answer is 7 and it can be shownthat answer cannot be less than7.Function DescriptionComplete the function getMinimum in theeditor below.getMinimum has the followingint n:given integerReturnsint: the minimun possihleparameter:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are your options besides a rote memory approach?

Answered: 1 week ago

Question

What irritates you the most about how others handle conflict? Why?

Answered: 1 week ago