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
1.Help Oz
Points:20
117 votes
Tags:
ApprovedEasyMathNumber TheoryOpen
Points:30
4 votes
Tags:
AlgorithmsDynamic ProgrammingCounting and Arrangements
Points:30
2 votes
Tags:
DP
Editorial
No editorial available for this problem.