Menger Sponge
시간 제한2초메모리 제한1024 MB
레벨 L과 단위 정육면체 안의 유리수 좌표 점이 주어질 때, 그 점이 레벨 L 멩거 스펀지에 속하는지 판정한다.
문제
The Menger sponge is a simple 3D fractal. Its level- approximation can be constructed with the following algorithm:
-
Start with a single solid cube with opposite corners at and .
-
For each iteration :
-
For each cube:
- Cut the cube into a regular grid of subcubes.
- Delete the seven subcubes that don’t touch an edge of the parent cube (see illustration).
-
The points in the level- Menger sponge are those that remain after running the above algorithm. Points exactly on the boundary of cubes that remain in the sponge are part of the sponge.
The picture below shows the result for through :

Given a level and a point in space given by three rational coordinates, determine if the point is in the level- Menger sponge.
입력
The single line of input contains seven integers , , , , , , :
where is the level of the Menger Sponge and the point in question is .
출력
Output a single integer, which is if the point is in the level- Menger Sponge, or if not.