SWEA 3376 파도반 수열

1 개요[ | ]

SWEA 3376 파도반 수열
SW Expert 아카데미
# 문제 풀이

틀:SWEA 난이도 3-4

2 C++[ | ]

3 Java[ | ]

import java.util.*;
public class Solution {
	public static void main(String[] args) {
		long[] P = new long[101];
		P[1] = P[2] = P[3] = 1;
		for(int i=4; i<=100; i++) {
			P[i] = P[i-2] + P[i-3];
		}
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int tc=1; tc<=T; tc++) {
			int N = sc.nextInt();
			System.out.format("#%d %d\n",tc, P[N]);
		}
		sc.close();
	}
}

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}