Scroll indicator done
728x90

 

 

풀이

 

코드
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int testCase = Integer.parseInt(br.readLine());
        int[] dp = new int[12];
        dp[1] = 1;
        dp[2] = 2;
        dp[3] = 4;
        for (int i = 4; i <= 11; i++) {
            dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1];
        }

        while (testCase-- != 0) {
            int n = Integer.parseInt(br.readLine());
            System.out.println(dp[n]);
        }
    }
}

https://github.com/jsl1113/algorithm/blob/main/sseni/week_1/B9095_1%2C2%2C3%EB%8D%94%ED%95%98%EA%B8%B0.java

728x90

'BAEKJOON > Java' 카테고리의 다른 글

[B15649,B15650,B15651][N과 M (1),(2),(3)][java]  (0) 2023.10.07
[B16439][치킨치킨치킨][java]  (0) 2023.10.07
[B1463][1로 만들기][java]  (0) 2023.10.07
[B1932][정수 삼각형][java]  (0) 2023.10.07
[B15686][치킨 배달][java]  (0) 2023.10.07