#SP0000030. Rút gọn về số nguyên tố (Prime Reduction)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Rút gọn về số nguyên tố (Prime Reduction)
Prime Reduction
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
An integer is prime if its only positive divisors are and itself. Every composite integer has a prime factorization, including repeated prime factors.
Perform prime reduction as follows:
- Check whether is prime. If so, stop.
- If is composite, factorize it into primes , including repetitions.
- Replace by the sum , then return to Step 1.
Find the final prime and the number of executions of Step 1, including the final check when is prime. The value is excluded because and the procedure would never terminate.
Input
One line containing the initial integer .
Output
Output two integers on one line, separated by one space: the final prime and the number of primality-check steps.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Example 1
Input
76
Output
23 2
Explanation: First check: is composite, with . The sum becomes the new value. Second check: is prime, so stop. Output 23 2.
Example 2
Input
100
Output
5 5
Explanation: The sequence is . The sums of prime factors are , then , then , then . Since is prime, five checks were performed. Output 5 5.
Example 3
Input
2
Output
2 1
Explanation: The first primality check finds that is prime, so no reduction occurs. There is still one check.