PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000088. Tổng nhỏ nhất với BCNN cho trước (Minimum Sum LCM)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng nhỏ nhất với BCNN cho trước (Minimum Sum LCM)
Minimum Sum LCM
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given a positive integer , choose a sequence of at least two positive integers (repetitions are allowed) whose LCM is exactly . Among all such sequences, find the minimum possible sum of the chosen integers. Print only this sum.
Input
One line containing a positive integer .
Output
Print the minimum possible sum.
Subtasks
- Subtask 1 (20 points):
- Subtask 2 (30 points):
- Subtask 3 (50 points):
Examples
Input
12
Output
7
Explanation
Choose and : their LCM is and their sum is . No valid sequence with LCM has a smaller sum.