#B4247. Sum of Miu Ling Number and Prime
Sum of Miu Ling Number and Prime
Sum of Miu Ling Number and Prime
Define a positive integer \(n\) as a Miu Ling number if there exists an integer \(m \ge 2\) such that \(m^2\) divides \(n\) (i.e. \(m^2 \mid n\)). A positive integer \(n\) is called a prime if \(n\) is not divisible by any integer in the range \(2 \ldots n-1\) (note that \(1\) is not a prime).
Given a positive integer \(n\), your task is to determine the number of ways to represent \(n\) as the sum of a Miu Ling number and a prime number. Among all such representations, find the minimum possible difference between the two numbers (always subtracting the smaller from the larger). If there is no valid representation, output the count as 0 and the minimum difference as -1.
Formally, count the number of pairs \((a, b)\) such that:
\[ \begin{cases} a + b = n,\\ a \text{ is a Miu Ling number (i.e. } \exists m \ge 2 \text{ with } m^2 \mid a\text{)},\\ b \text{ is prime.} \end{cases} \]and let \(d = |a - b|\) (with the convention of subtracting the smaller from the larger). Report the count and the minimum \(d\) over all valid pairs.
inputFormat
The input consists of a single line containing a positive integer \(n\) (\(1 \le n \le 10^5\)).
outputFormat
Output two space-separated integers: the first is the number of valid representations and the second is the minimum difference between the Miu Ling number and the prime number in those representations. If no representation exists, output 0 and -1 respectively.
sample
9
1 1