[백준] P9095

동민·2021년 3월 11일
0
import java.util.ArrayList;
import java.util.Scanner;

public class P9095 { // DFS
	private static int cnt = 0;
	private static ArrayList<Integer> list = new ArrayList<>();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			dfs(sc.nextInt(), 0);
			list.add(cnt);
			cnt = 0;
		}
		for (int ele : list) {
			System.out.println(ele);
		}
		sc.close();
	}

	private static void dfs(int target, int current) {
		if (target <= current) {
			if (target == current) {
				cnt++;
			}
			return;
		}
		dfs(target, current + 1);
		dfs(target, current + 2);
		dfs(target, current + 3);
	}
}
profile
BE Developer

0개의 댓글