PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000087. Sắp xếp theo số thừa số nguyên tố có lặp (A Different Kind of Sorting)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Sắp xếp theo số thừa số nguyên tố có lặp (A Different Kind of Sorting)
A Different Kind of Sorting
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Consider all integers from through , sorted by the total number of prime factors counting multiplicity, ascending. Ties are broken by smaller integer first. The integer has zero prime factors. For example, has three factors, while has two. Given a -based rank , output the number at that rank.
Input
One line contains the rank .
Output
Print one line in the exact format Case 1: x, where is the value at rank .
Subtasks
- Subtask 1 (20 points): ; sorting domain is exactly .
- Subtask 2 (30 points): ; sorting domain is exactly .
- Subtask 3 (50 points): ; sorting domain is exactly .
Examples
Input
4
Output
Case 1: 5
Explanation
The integer has zero prime factors and comes first. All primes have exactly one prime factor and appear as . The first four elements are therefore , so rank contains and the output is Case 1: 5.