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\)
Submissions
Please login to view your submissions
Similar Problems
1.Coprimes
Points:10
41 votes
Tags:
Ad-HocAlgorithmsCoprimeEasyGreedy Algorithms
Points:10
14 votes
Tags:
Basics of Greedy AlgorithmsGreedy AlgorithmsAlgorithms
Points:10
11 votes
Tags:
HashingGreedy AlgorithmsBasics of Greedy AlgorithmsAlgorithms
Editorial