You are given
coins whose values are from to . The value of each coin ranges from to . You want to gift as many people as you can.
You also want to be fair with everyone and therefore, you prepare the gift such that each person can be gifted the same amount of money. You are allowed to put several denominations together in a gift. What is the maximum number of gifts that you can prepare?
Example:
Input: n=4
Output: 2
Approach
Java
public class ProvidinGifts {public static void main(String args[]) {int n = 4;System.out.println((int) Math.ceil(n / 2.0));}}
No comments:
Post a Comment