시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB94524551.724%

문제

Suppose you are given a sequence of N integer-valued vectors in the plane (xi, yi), i = 1, . . . , N. Beginning at the origin, we can generate a path by regarding each vector as a displacement from the previous location. For instance, the vectors (1, 2), (2, 3), (−3, −5) form the path (0, 0),(1, 2),(3, 5),(0, 0). We define a path that ends at the origin as a circuit. The example just given is a circuit. We could form a path using any nonempty subset of the N vectors, while the result (circuit or not) doesn’t depend on the ordering of the subset. How many nonempty subsets of the vectors form circuits?

For instance, consider the vectors {(1, 2),(−1, −2),(1, 1),(−2, −3),(−1, −1)} From these vectors we can construct 4 possible subset circuits using

{(1, 2), (−1, −2)}
{(1, 1), (−1, −1)}
{(1, 2), (1, 1), (−2, −3)}
{(1, 2), (−1, −2), (1, 1), (−1, −1)}

입력

Input begins with an integer N ≤ 40 on the first line. The next N lines each contain two integer values x and y forming the vector (x, y), where |x|, |y| ≤ 10 and (x, y) ≠ (0, 0). Since the given vectors are a set, all vectors are unique.

출력

Output the number of nonempty subsets of the given vectors that produce circuits. It’s guaranteed that the answer is less than 1010.

예제 입력 1

5
1 2
1 1
-1 -2
-2 -3
-1 -1

예제 출력 1

4

출처

ICPC > Regionals > North America > North America Qualification Contest > ACM-ICPC North America Qualifier 2015 D번

  • 문제의 오타를 찾은 사람: corea
  • 문제를 만든 사람: Christopher Raphael