Father Trouble Problem
Anonymous User
2514

Hello guys, Can you help me to slove this problem?

Jack is an old farmer in his late 80s. He wants to divide his farming land between his three sons. But he
needs to
do it very caretully because he knows his sons are not in good terms with each other. He nas
decided to do it in following manner:

  1. The production rate of each piece of land is different, and he wants
    divide the land properly, i
    such a way that each of his sons gets equal amounts of production, otherwise, there may be a
    dispute between them.
    He also wants to give them k options, so they can
    choose among the given options and everyone
    is satistied.
  2. 1o avoid a dispute, he wants each son to have his separate land, i.e. all the pieces of the land
    which are given to a particular son should be together.
    He asks for your help. He has given you k options and asks you to find outtif he has at least k options to
    offer to his sons, so that everyone lives happily.
    Input Specification
    input1: Number of pieces in which the land is divided
    input2: Number of options he wants to nave
    input3: An
    array in which input3i represents the production rate of ith piece of
    lano
    Output Specification
    Your function
    should return a string containing Yes followed by number of
    options he has. if he has at least k options otherwise return a string containing
    No followed by number of options he lacks from his target options.

Example
input: o
inout2: 3
input3: 2.2.2
Outout: No 2
Exolanation:
He can divide
the land in the following manner:
Each
piece will be given to each son. But he needs 2 options, hence output would be. No 1.

Comments (2)