Logo
(追記) (追記ここまで)

32505번 - Menger Sponge 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB58353282.051%

문제

The Menger sponge is a simple 3D fractal. Its level-$L$ approximation can be constructed with the following algorithm:

  • Start with a single solid 1ドル \times 1 \times 1$ cube with opposite corners at $(0,0,0)$ and $(1,1,1)$.
  • For each iteration $i=1, \dots ,L$:
    • For each cube:
      • Cut the cube into a regular 3ドル \times 3 \times 3$ grid of 27ドル$ subcubes.
      • Delete the seven subcubes that don’t touch an edge of the parent cube (see illustration).

The points in the level-$L$ 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 $L=0$ through $L=3$:

Given a level $L$ and a point in space given by three rational coordinates, determine if the point is in the level-$L$ Menger sponge.

입력

The single line of input contains seven integers $L,ドル $x_{\text{num}},ドル $x_{\text{denom}},ドル $y_{\text{num}},ドル $y_{\text{denom}},ドル $z_{\text{num}},ドル $z_{\text{denom}}$:

  • 0ドル≤L≤10^5$
  • 0ドル<x_{\text{num}}<x_{\text{denom}}≤10^6$
  • 0ドル<y_{\text{num}}<y_{\text{denom}}≤10^6$
  • 0ドル<z_{\text{num}}<z_{\text{denom}}≤10^6$

where $L$ is the level of the Menger Sponge and the point in question is $\displaystyle\left(\frac{x_{\text{num}}}{x_{\text{denom}}}, \frac{y_{\text{num}}}{y_{\text{denom}}}, \frac{z_{\text{num}}}{z_{\text{denom}}}\right)$.

출력

Output a single integer, which is 1ドル$ if the point is in the level-$L$ Menger Sponge, or 0ドル$ if not.

제한

예제 입력 1

1000 1 3 1 3 1 3

예제 출력 1

1

예제 입력 2

2 49 81 5 6 20 81

예제 출력 2

1

예제 입력 3

3 49 81 5 6 20 81

예제 출력 3

0

힌트

출처

ICPC > Regionals > North America > North America Qualification Contest > ICPC North America Qualifier 2024 J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /