#C6134. Perfect Square of Sum of Squares of Digits

    ID: 49861 Type: Default 1000ms 256MiB

Perfect Square of Sum of Squares of Digits

Perfect Square of Sum of Squares of Digits

You are given a positive integer \(N\). Your task is to compute the sum of the squares of its digits, i.e., compute \(\sum_{i=1}^k d_i^2\) where \(d_i\) represents the \(i^{th}\) digit of \(N\). After calculating the sum, determine whether the sum is a perfect square.

A number \(S\) is a perfect square if there exists an integer \(m\) such that \(m^2 = S\). If the computed sum is a perfect square, output 1; otherwise, output 0.

Example:

  • For \(N=1\), since \(1^2 = 1\) and 1 is a perfect square, the output should be 1.
  • For \(N=81\), the sum of squares is \(8^2 + 1^2 = 64 + 1 = 65\), which is not a perfect square, so the output should be 0.

inputFormat

The input consists of a single integer (N), provided via the standard input (stdin).

outputFormat

Output a single integer to the standard output (stdout): print 1 if the sum of the squares of the digits of (N) is a perfect square, otherwise print 0.## sample

81
0