PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000399. Phân số nguyên tố nhỏ thứ k (K-th Smallest Prime Fraction)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Phân số nguyên tố nhỏ thứ k (K-th Smallest Prime Fraction)
K-th Smallest Prime Fraction
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given a strictly increasing integer sequence with and every other element prime, form one fraction for each pair . Order these fractions by increasing value. Determine the numerator and denominator of the fraction at rank (starting at 1).
Input
The first line contains integers . The second line contains integers .
Output
Print two space-separated integers: the numerator followed by the denominator.
Subtasks
- Subtask 1 (20 points): ; ; ; is prime for every .
- Subtask 2 (30 points): ; ; ; ; is prime for every .
- Subtask 3 (50 points): ; ; ; is prime for every .
Examples
Input
4 3
1 2 3 5
Output
2 5
Explanation
The increasing sequence is . Rank 3 is , giving 2 5.
Input
2 1
1 7
Output
1 7
Explanation
The sole pair forms , which is the first fraction.