#SP0000024. Thiết kế hệ thống mệnh giá tối đa (Coins)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Thiết kế hệ thống mệnh giá tối đa (Coins)
Coins
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Berland is introducing new coin denominations. The largest denomination must equal , all denominations must be distinct positive integers, and the denomination of each coin must be divisible by the denomination of every cheaper coin. Maximize the number of distinct denominations and print any optimal list in decreasing order.
Input
One line contains the positive integer , the largest denomination.
Output
Print the denominations of any maximum-cardinality valid system on one line, in decreasing order separated by spaces. Multiple outputs may be valid.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
10
Output
10 5 1
Explanation
The denominations are strictly decreasing and each larger value is divisible by every smaller one. Since has two prime factors with multiplicity, no divisibility chain can contain more than three denominations.
Input
4
Output
4 2 1
Explanation
The valid chain is . There can be at most three denominations since has two prime factors with multiplicity.
Input
3
Output
3 1
Explanation
The prime has only divisors and , so the two-denomination chain is optimal.