Providing gifts

3.7

23 votes
Algorithms, Basics of Greedy Algorithms, Greedy Algorithms
Problem

You are given \(N\) coins whose values are from \(1\) to \(N\). The value of each coin ranges from \(1\) to \(N\). 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?

Note: It does not make sense to prepare empty gifts.

Input format

  • The first line contains \(T\) denoting the number of test cases.
  • The first and only line of each test case contains an integer \(N\) as described in the problem statement.

Output format

For each test case, print a single integer consisting of the maximum number of gifts.

Constraints

\(1 \leq T \leq 20000\)

\(1 \leq N \leq 10^9\)

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Suppose you decide that each gift should be worth 3 units. We can put (1,2) in one gift and (3) in another so we will have 2 gifts. There is no more optimal strategy.

Editor Image

?