- 1

Pens problem

Mr. Russo is in his 60s and he loves traveling. He recently visited a country famous for its pens. He wants to gift a few pens as souvenirs to his grandchildren. Mr. Russo has N grandchildren so he visited a pen shop to purchase pens for them. The shopkeeper showed him A varieties (types) of pens, each variety (type) consisting of B number of pens. He has to select only C varieties (types) of pens in a set in such a way that when he distributes these pens among his grandchildren, each of them gets the same number of pens. If there are more than one such sets or combinations possible, then the set contributing to minimum number of pens per grandchild should be selected and the number of pens that every grandchild gets should be returned. Your task is to help Mr. Russo in finding the minimum number of pens each grandchild can get. Note: If no solution is possible, return -1 as your output. Input Specification: input1: An integer value A, denoting the variety of pens that the shopkeeper owns. input2: An integer value C, denoting the variety of pens to be selected by Mr. Russo. input3: An integer value N, denoting the number of grandchildren. input4: An integer array B, containing number of pens for each variety.

14th Aug 2021, 1:51 PM
sarayu
sarayu - avatar
7 Answers
+ 10
sarayu , before we are going to help you, please present your attempt here. if you haven't done a try by yourself so far, please do so. => create your code in playground and post the link to it here. thanks!
14th Aug 2021, 1:54 PM
Lothar
Lothar - avatar
+ 1
Answer?
13th Aug 2022, 1:31 PM
SAKALABATHULA SMARAN (RA1911004010382)
SAKALABATHULA SMARAN (RA1911004010382) - avatar
0
Jhg
24th Jan 2022, 1:13 PM
Banothu Suman
0
answer
13th Aug 2022, 1:00 PM
Kalyani Manda
Kalyani Manda - avatar
13th Aug 2022, 1:54 PM
Sudeep
Sudeep - avatar
0
Hhhgf
31st Aug 2022, 3:38 AM
Rashmi Ranjan
Rashmi Ranjan - avatar
0
Please answer
8th Oct 2023, 1:02 PM
Rakesh Kumar
Rakesh Kumar - avatar