snails

시간 제한16초메모리 제한2048 MB

요약
수열이 0, 1, 2, 3으로 시작해 앞의 네 항을 더해 이어지는 사각나선(tetranacci) 패턴과 일치하는지 판정한다.
난이도

쉬움10점 중 3점

유형
구현, 배열
정답자
아직 제출이 없습니다

문제

In prehistoric times, there were many creatures with shells that lived in the ocean. You are part of a team of researchers who are looking at a collection of shell fossils with spiral shapes. You want to determine what kind of animal each one came from.

For each shell, you have taken a sequence of measurements along the spiral part. It is hypothesized that if the measurements M_1 M_2 … M_k M\_1\ M\_2\ \ldots\ M\_k for a given shell follow the pattern of the following sequence, it is a nautilus shell: \begin{align*} M_1 &= 0 \\ M_2 &= 1 \\ M_3 &= 2 \\ M_4 &= 3 \\ M_{k} &= M_{k-1} + M_{k-2} + M_{k-3} + M_{k-4} & \text{when k>4k > 4} \end{align*} Otherwise, it is a snail shell.

The team has collected a very large number of measurements. Being the member with the most programming experience, you have been asked to write a computer program to automate the task of determining whether each sequence of measurements is for a snail shell or nautilus shell.

입력

The first line of input shall be nn, the number of lines of input that follow, where 1≤n<2151 \leq n < 2^{15} .

The subsequent nn lines of input shall each be a sequence of kk (where 1≤k<2151 \leq k < 2^{15}) measurements M_1 M_2 … M_kM\_1\ M\_2\ \ldots\ M\_k pertaining to one shell fossil. Measurements are separated by spaces. Each measurement shall be in the range 0≤M<2320 \leq M < 2^{32}.

출력

For each line of input where the measurements came from a nautilus shell, the output shall be a line with only NAUTILUS. For each line of input where the measurements came from a snail shell, the output shall be a line with only SNAIL.

예제1

  1. 예제 1

    입력
    4
    0 1 2
    0 1 1 2
    0 1 2 3 4
    0 1 2 3 6
    
    예상 출력
    NAUTILUS
    SNAIL
    SNAIL
    NAUTILUS