Ordering Number

Ordering Number

Time Limit: 1.0 s

Memory Limit: 64.0 MB

Number v is a Divisor of a number u, if u is divisible by v.

Given an array, order it by the following condition.

x will come before y if

  • number of divisors of x is less than number of divisors of y
  • number of divisors of x is equal to number of divisors of y and x > y.

After ordering, print the kth number.

Input format:

T number of case, T <= 100
N = size of array, N <= 1000
A[i].....A[n] = array. A[i] <= 10000
K = kth number to print. K <= N

Output format:

X, where X = kth number after ordering the array.

Sample Input:

2
10
1 2 3 4 5 6 7 8 9 10
5
5
1 2 3 5 7
3

Sample Output:

2
5

Information

ID
1008
Difficulty
3
Category
Implementation | Sorting Click to Show
Tags
(None)
# Submissions
31
Accepted
19
Accepted Ratio
61%
Uploaded By

Related

In following contests:

Beta Round #1