#K58752. Square Word Checker
Square Word Checker
Square Word Checker
Given a non-empty word, determine whether it is a "square word". A word is defined as a square word if the sum of the squares of the indices (1-indexed) of its characters is a perfect square. In other words, for a word of length n, compute
\( S = \sum_{i=1}^{n} i^2 \)
and check whether there exists an integer \( r \) such that \( r^2 = S \). Output true
if \( S \) is a perfect square and false
otherwise.
Note: The input will be read from standard input and the output should be printed to standard output.
inputFormat
The input consists of a single line containing a non-empty string word
without any spaces.
outputFormat
Print true
if the sum of the squares of the indices of the characters (1-indexed) forms a perfect square; otherwise, print false
. The output should be printed on standard output.
a
true