PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000179. Tổng các ước thực sự (Divisor Summation)
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 các ước thực sự (Divisor Summation)
Divisor Summation
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
A positive integer is a proper divisor of a positive integer when and .
For example, the proper divisors of are , whose sum is . The number itself is excluded.
Given a positive integer , print the sum of all its proper divisors. The sum is when there are no proper divisors.
Input
One line containing the integer .
Output
Print one integer: the sum of the proper divisors of .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
20
Output
22
Explanation
The positive divisors are . Exclude and add the rest to obtain .
Example 2
Input
1
Output
0
Explanation
has no positive divisor strictly smaller than itself, so the sum is .