Digits and Fun
Practice
0 (0 votes)
Medium
Problem
7% Success 101 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Given a set of N digits, find the \(k^{th}\) smallest number that can be formed using them such that the sum of its digits is prime. If the answer does not exists or is greater than \(10^{18}\) print 1.
Input:
First line consists of a single integer T denoting the number of test cases.
Second line consists of a single integer denoting N.
Third line consists of N space separated numbers denoting the set of digits.
Fourth line consists of a single integer denoting k.
Output: Print the required answer in a new line for each test case.
Constraints:
\(1 \le N \le 9\)
\(1 \le k \le 10^{18}\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
49 votes
Tags:
Dynamic ProgrammingRecursionMediumMathematicsOpenApproved
Points:30
58 votes
Tags:
ReadyMathematicsDynamic ProgrammingMedium
Points:30
1 votes
Tags:
Dynamic ProgrammingAlgorithmsMediumSimple-math
Editorial
No editorial available for this problem.