Jack and Jill were passing through a jungle on there way. They
encountered a monster who told they will be only be allowed to
escape when
they solve a puzzle for him. They did't have choice so agreed.
Given N number of empty buckets, we need to minimize steps to fill
required number of fruits in each bucket. Only below mentioned
operations are allowed to add fruits.
1. Double the count of fruits - All buckets will double the number of
fruits in single operation.
2. Increment individual bucket fruit count by 1.Single operation for
each bucket
3. We cannot remove/decrease number of fruits in a bucket.
CONSTRAINTS:
1<=target[i]<=1000, where target[i] is the element at index Y.
1<=i<= 1000
Answers
Answered by
1
Answer:
Good For Digestion. ...
Anti-inflammatory. ...
Fights free radical activity. ...
Skin Benefits. ...
Fights Depression. ...
Diabetes Management. ...
Supports Liver Function and Helps Detoxify the Body. ...
Promote healthy gut
Answered by
0
The function that will help to solve the puzzle is as follows.
Given:
The number of empty buckets = N.
CONSTRAINTS:
1<=target[i]<=1000, where target[i] is the element at index "Y".
1<= i <= 1000.
To Find:
We need to minimize the steps to fill the required number of fruits in each of the N number of empty buckets using a C++ program.
Solution:
The C++ program to solve the given puzzle is given below.
- In order to solve the given puzzle, we need to minimize the steps to fill the required number of fruits in each of the N number of empty buckets.
- The parameters in the program are an integer array that denotes the number of fruits required in the bucket and another integer denoting the number of the buckets.
- Danish computer scientist Bjarne Stroustrup developed the high-level programming language C++ as an extension of the C programming language.
Hence, the C++ program to solve the puzzle is given.
#SPJ2
Attachments:
Similar questions