Beautiful Array
Practice
4.3 (121 votes)
Mathematics
Medium
Problem
84% Success 323 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code
Kevin thinks that array A is beautiful if
- It contains N positive integers.
- It doesn't contain any bad numbers.
- There doesn't exist any number x and tuple (y1, y2, ..., yK) such that Ax = Ay1 · Ay2 · ... · AyK (yi < x).
Kevin knows M bad numbers Bi. Kevin also knows that 1 isn't a bad number. Now he wants to find lexicographically smallest beautiful array.
Input format:
The first line of the input contains three numbers N, K, M. The next line contains M integers - Bi.
Output format:
Output N integers - lexicographically smallest beautiful array.
Constraints:
- 2 ≤ N, K ≤ 2 · 104
- 0 ≤ M ≤ 2 · 104
- 0 ≤ Bi ≤ 109
- N, M, K ≤ 100 in test data worth 20% of all points
- M = 0 in test data worth 20% of all points
Code Editor
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
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
8 votes
Tags:
AlgorithmsBinary SearchDepth First SearchDisjoint setEasyGraphsLife-cycle assessmentSearching
Points:30
9 votes
Tags:
Mediumad hocapproved
Points:30
31 votes
Tags:
AlgorithmsApprovedBit ManipulationDynamic ProgrammingMediumOpen
Editorial
Login to unlock the editorial
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
Results
Custom Input
Run your code to see the output