PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000190. Trừ ước nguyên tố nhỏ nhất (Divisor Subtraction)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Trừ ước nguyên tố nhỏ nhất (Divisor Subtraction)
Divisor Subtraction
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer , repeatedly do the following until : choose the smallest prime divisor of the current positive , then replace with . Find the total number of subtractions. The divisor is chosen from the current value each time.
Input
The input contains .
Output
Print the number of subtractions.
Subtasks
-
Subtask 1 (20 points): .
-
Subtask 2 (30 points): .
-
Subtask 3 (50 points): .
Examples
Example 1
Input
5
Output
1
Explanation
The smallest prime divisor of is itself, so the process reaches zero in one subtraction.
Example 2
Input
4
Output
2
Explanation
The successive values are , requiring two subtractions of .