Bobby Tables
Time limit2sMemory limit512 MB
Given the prime factorization of X and a bound m, find n and k with 0 <= k <= n <= m and X = C(n, k), or report NO.
- Level
Medium7 of 10
- Topics
- Number theory, Combinatorics, Brute force
- Solved
- No attempts yet
Problem
Little Bobby Tables stores his favorite big numbers in his database. Those numbers take a lot of memory, so he is trying to find a more efficient way to store them.
The database holds a number with no large prime factors. Bobby suspects that has the form for some relatively small integers and .
Given an integer and the prime factorization of , determine whether there exist integers and such that and .
Input
The first line contains the number of test cases (). Each test case is described as follows.
The first line of a test case contains two integers and (), where is the number of primes in the factorization of and is the upper bound for the output values.
The second line contains primes () whose product is .
The sum of over all test cases does not exceed . The sum of over all test cases does not exceed .
Output
For each test case, if there exist suitable and , print "YES" on the first line and the values of and on the second line. Otherwise, print only "NO" on one line.