B. Ordering Number

B. 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

Hint

C Code

#include <stdio.h>
int main(void)
{
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", a + b);
    return 0;
}

C++ Code

#include <iostream>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
    return 0;
}

C# Code

using System;
using System.Linq;

class Program {
    public static void Main(string[] args) {
        Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).Sum());
    }
}

Python3 Code

a, b = list(map(int, input().split()))
print(a + b)

Java Code

import java.io.*;
import java.util.Scanner;

public class Main {

    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a + b);
    }
}

Ruby Code

a, b = gets.split.map(&:to_i)
puts(a + b)

Source

Information

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

Related

In following contests:

Beta Round #1