본문 바로가기
알고리즘 & 자료구조/백준

백준 15991

by 신재권 2022. 1. 26.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main15991 {
	
	public static final int MOD = 1_000_000_009;

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
		int T = Integer.parseInt(br.readLine()); //테스트 케이스 T
		long[] D = new long[100001];
		//D[i] = 정수 i를 만드는 대칭을 이루는 합을 나타내는 방법의 갯수 
		//1+대칭+1
		//2+대칭+2
		//3+대칭+3
		//D[i] = D[i-2] + D[i-4] + D[i-6] % mod;
		
		D[0] = 0;
		D[1] = 1;
		D[2] = 2;
		D[3] = 2; 
		D[4] = 3;
		D[5] = 3;
//		1 1 1 1 1
//		2 1 2
//		1 3 1
		D[6] = 6; 
//		1 1 1 1 1 1
//		1 1 2 1 1
//		1 2 2 1
//		2 1 1 2
//		2 2 2
//		3 3
		
		for(int i=7; i<100001; i++) {
			D[i] = (D[i-2] + D[i-4] + D[i-6]) % MOD;
		}

		
		
		while(T-- > 0) {
			int N = Integer.parseInt(br.readLine());
			System.out.println(D[N]);
		}
	}
	
	
	
}

 

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 10808  (0) 2022.01.28
백준 2309_1  (0) 2022.01.27
백준 1633  (0) 2022.01.25
백준 14651  (0) 2022.01.24
백준 16500  (0) 2022.01.23