본문 바로가기

CS/Algorithm

[Python] 백준 33675번: L-트로미노 타일링

반응형

https://www.acmicpc.net/problem/33675

 

 

 

[풀이]

타일의 세로 길이는 무조건 3

가로 길이가 2의 배수여야 각각 2개의 방법씩 대입할 수 있다.

 

가로의 길이가 N이라면,

짝수인 경우, 해당 방법은 2 * (N // 2)만큼 나올 수 있다.

홀수인 경우, 0개이다. (빈 공간이 발생하기 때문)

 

 

 

[코드]

import sys
input = lambda: sys.stdin.readline().rstrip()

result = []
for _ in range(int(input())):
    n = int(input())
    x = int(2 ** (n / 2))
    if n % 2 == 0:
        result.append(str(x))
    else:
        result.append(str(0))
print('\n'.join(result))

 

 

 

[시간복잡도]

O(1)

 

반응형