B. Ordering Number

B. Ordering Number

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

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

Beta Round #1

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
5
Start at
2023-11-29 16:00
End at
2023-11-29 18:00
Duration
2.0 hour(s)
Host
Partic.
23