/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 213ms 3.406 MiB

Code

def count_divisors(n):
  count = 0
  for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
      count += 2
      if i == n // i:
        count -= 1
  return count
def compare(x, y):
  if count_divisors(x) < count_divisors(y):
    return -1
  elif count_divisors(x) > count_divisors(y):
    return 1
  else:
    if x > y:
      return -1
    elif x < y:
      return 1
    else:
      return 0
def sort_array(arr):
  return sorted(arr, key=lambda x: (count_divisors(x), -x))
def print_kth_number(arr, k):
  sorted_arr = sort_array(arr)
  print(sorted_arr[k-1])

T = int(input())
for _ in range(T):
  N = int(input())
  arr = list(map(int, input().split()))
  k = int(input())
  print_kth_number(arr, k)

Information

Submit By
Type
Submission
Problem
P1008 Ordering Number
Language
Python 3 (Python 3.12.3)
Submit At
2024-01-08 19:00:46
Judged At
2024-11-11 03:43:40
Judged By
Score
100
Total Time
213ms
Peak Memory
3.406 MiB