[BOJ 9095] 123더하기

Leehyemin·2023년 3월 12일
0

알고리즘_백준

목록 보기
6/7
#include <iostream>
using namespace std;
// 9095 123 더하기
// Created by polcom, 230307

int func(int n){
    if (n<0) return 0;
    else if(n==0) return 1;
    else return (func(n-1)+ func(n-2) + func(n-3));
}

int main(){
    int T=0;
    cin >> T;
    int res[T+1];
    for(int t=0; t<T; t++){
        int N = 0;
        cin >> N;
        for (int n = 1; n<=N; n++){
            res[t]=func(n);
            // cout << "temp" << res[t] << endl;

        }
        // cout << "e" <<  endl;

    }

    for(int t=0; t<T; t++){
        cout << res[t] << endl;

    }

    return 0;
}

0개의 댓글