Shil and Lab Assignment
Practice
3.6 (9 votes)
Approved
Graphs
Matching
Math
Medium
Ready
Problem
71% Success 2738 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
For the lab assignment of this week , Shil got N numbers A1 , A2, ... AN. He must assign each of these numbers a unique integer value from 1 to M. Let Ci be the integer assigned to Ai . Shil must assign numbers in such a way that maximum number of Ai are divisible by their Ci . You must print maximum numbers of Ai that could be made divisible by Ci in optimal assignment.
Input:
First Line of input consists of integer N and M.
Next N lines consists of N integers with ith line containing integer Ai.
Output:
Output maximum number of Ai that can be made divisible by Ci in optimal assignment.
Constraints:
- 1 ≤ N ≤ 103
- 1 ≤ Ai ≤ 105
- N ≤ M ≤ 105
Submissions
Please login to view your submissions
Similar Problems
Points:30
5 votes
Tags:
AlgorithmsFlowMediumOpen
Editorial