#P9076. Password Recovery
Password Recovery
Password Recovery
Bytie forgot his phone password. He remembers that it consists of three different positive integers \(a, b, c\) such that \(a < b < c\) and \(a + b + c = n\). Moreover, for every pair among \((a,b)\), \((a,c)\) and \((b,c)\) one number is a multiple of the other. In other words, the following conditions must hold:
- \(b \equiv 0 \; (\bmod\; a)\)
- \(c \equiv 0 \; (\bmod\; a)\)
- \(c \equiv 0 \; (\bmod\; b)\)
Your task is to help Bytie compute the number of possible triples \((a,b,c)\) satisfying the above conditions.
Mathematical Transformation:
Since \(a, b, c\) satisfy \(a < b < c\) and the divisibility conditions, if we set \(b=k\cdot a\) (with \(k\ge2\)) and \(c=m\cdot b=m\cdot k\cdot a\) (with \(m\ge2\)), then the sum becomes:
[ a + k,a + m,k,a = a(1+k+m,k)=n. ]
Thus, for every divisor \(a\) of \(n\) with \(X = n/a\), we must have:
[ 1+k+m,k=X,\quad\text{or}\quad k(m+1)=X-1. ]
The task reduces to iterating over divisors \(a\) of \(n\) and counting for how many choices of \(k\ge2\) (dividing \(X-1\)) we get an integer \(m\) (with \(m\ge2\)) from \(m = \frac{X-1}{k} - 1\).
inputFormat
The input consists of a single integer \(n\) (\(1 \le n \le\) some upper bound), representing the sum of the three numbers.
outputFormat
Output a single integer: the number of valid triples \((a,b,c)\) satisfying the given conditions.
sample
7
1