Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions KHJ_Root/백준문제/백준9095.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

int t = sc.nextInt();
int[] dp = bew int[12];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오타 발견!

Suggested change
int[] dp = bew int[12];
int[] dp = new int[12];

dp[1] = 1;
dp[2] = 2;
dp[3] = 4;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요부분 인덱스 오류 안 나나여?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

돌려봐야 알긴 합니다만 dp = new int[13] 하는게 더 맞겠네여


for (inr i = 4; i <= 11; i++) {
dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
}

for (int i = 0; i < t; i++) {
int n = sc.nextInt();
System.out.println(dp[n]);
}
}
}