#K41772. Kaprekar Number Checker
Kaprekar Number Checker
Kaprekar Number Checker
A Kaprekar Number is a non-negative integer \(n\) such that when you square it, the resulting number can be split into two parts whose sum is equal to \(n\). More formally, if \(d\) is the number of digits in \(n\), and we write \(n^2\) as a string, then splitting \(n^2\) into a left part \(L\) and a right part \(R\) (with \(R\) having exactly \(d\) digits, possibly with leading zeros) should satisfy
[ n^2 = L \times 10^d + R \quad \text{and} \quad L + R = n. ]
For example, for \(n = 45\):
- \(45^2 = 2025\)
- Split as \(L = 20\) and \(R = 25\) (since 45 has two digits)
- \(20 + 25 = 45\) so 45 is a Kaprekar Number.
Your task is to implement a program that reads a non-negative integer from standard input and prints True
if it is a Kaprekar Number, and False
otherwise.
inputFormat
The input consists of a single line containing one non-negative integer \(n\). The input is given via standard input.
outputFormat
Output True
if the number is a Kaprekar Number, otherwise output False
. Output is printed to standard output.
45
True