분할정복 제곱. 근데 그냥 pow써도 되는듯..
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
def pow(n):
if n<=0:
return 1
p_n = pow(n//2)
if n&1:
return p_n*p_n*2%MOD
return p_n*p_n%MOD
MOD = int(1e9)+7
for _ in range(int(input())):
N = int(input())
# 2~N-1 번의 징검다리를 선택하거나 선택하지 않는 모든 경우의 수.
print((pow(N-2))%MOD)
'practivceAlgorithm > 백준' 카테고리의 다른 글
[백준][Python] 10165 버스노선 (0) | 2021.09.08 |
---|---|
[백준][Python] 2170 선긋기 (0) | 2021.09.08 |
[백준][Python] 2406 안정적인 네트워크 (0) | 2021.09.07 |
[백준][Python] 5569 출근경로 (0) | 2021.09.07 |
[백준][Python] 15991 1,2,3더하기 6 (0) | 2021.09.07 |