Skip to content

Commit 12646fe

Browse files
committed
BOJ_2502 : 떡 먹는 호랑이
1 parent f35e366 commit 12646fe

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
public class Main {
5+
6+
public static void main(String[] args) throws IOException {
7+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
StringTokenizer st = new StringTokenizer(br.readLine());
9+
int D = Integer.parseInt(st.nextToken());
10+
int K = Integer.parseInt(st.nextToken());
11+
for(int i=1; i<=K; i++) {
12+
int[] d = new int[D+1];
13+
d[1] = i;
14+
for(int j=i; j<=K; j++) {
15+
d[2] = j;
16+
for(int k=3; k<=D; k++) {
17+
d[k] = d[k-2] + d[k-1];
18+
}
19+
if(d[D] == K) {
20+
System.out.println(d[1]);
21+
System.out.println(d[2]);
22+
return;
23+
}
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)