Square Root Partitioning

시간 제한3초메모리 제한512 MB

요약
n개의 제곱근에 부호를 붙여 합이 정확히 0이 되는 경우의 수를 구한다.
난이도

어려움10점 중 8점

유형
수학, 정수론, 완전 탐색
정답자
아직 제출이 없습니다

문제

Consider the following expression:

\[\sqrt{a_1} \pm \sqrt{a_2} \pm \cdots \pm \sqrt{a_n} = 0\text{.}\]

Calculate the number of ways to replace each \(\pm\) with \(+\) or \(-\) so that it holds true.

입력

The first line of input contains a single integer \(n\) (\(2 \le n \le 36\)).

Second line of input contains \(n\) integers \(a_1, a_2, \dots , a_n\) (\(1 \le a_i \le 10^{10^5}\)).

출력

Output a single integer: the answer to the problem.

예제2

  1. 예제 1

    입력
    3
    2 2 8
    
    예상 출력
    1
    
  2. 예제 2

    입력
    4
    4 9 25 49
    
    예상 출력
    0