PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000251. Liệt kê các phân số hữu tỉ (Enumerating Rational Numbers)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Liệt kê các phân số hữu tỉ (Enumerating Rational Numbers)
Enumerating Rational Numbers
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Consider a sequence of rational numbers. For each denominator in increasing order, inspect numerators and append exactly when . The sequence starts . Given a one-based position , find the fraction at that position.
Input
One line contains the integer .
Output
Print the fraction at position in the format p/d, without spaces.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
1
Output
0/1
Explanation
The first fraction is 0/1.
Example 2
Input
2
Output
1/1
Explanation
The second fraction is 1/1.
Example 3
Input
3
Output
1/2
Explanation
Denominator 2 contributes fraction 1/2.
Example 4
Input
12158598919
Output
199999/200000
Explanation
The last fraction with denominator 200000 is 199999/200000.