Providing gifts
Practice
3.7 (23 votes)
Algorithms
Basics of greedy algorithms
Greedy algorithms
Problem
58% Success 3214 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
6 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsC++Greedy Algorithms
Points:10
14 votes
Tags:
Basic ProgrammingAlgorithmsBasics of Greedy AlgorithmsGreedy Algorithms
Points:10
9 votes
Tags:
Greedy AlgorithmsAlgorithmsStringBasics of Greedy Algorithms