Skip to content

Commit e5636ca

Browse files
authored
Merge pull request #1717 from AlgorithmWithGod/khj20006
[20251220] BOJ / G4 / Messi Gimossi / 권혁준
2 parents 145d96b + 57309f9 commit e5636ca

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
```java
2+
import java.sql.Array;
3+
import java.util.*;
4+
import java.io.*;
5+
6+
public class Main {
7+
8+
static BufferedReader br;
9+
static BufferedWriter bw;
10+
11+
static int N, K = 0;
12+
static int[] len;
13+
14+
public static void main(String[] args) throws Exception {
15+
16+
input();
17+
solve();
18+
19+
}
20+
21+
public static void input() throws Exception {
22+
br = new BufferedReader(new InputStreamReader(System.in));
23+
24+
N = Integer.parseInt(br.readLine());
25+
len = new int[100];
26+
len[1] = 5;
27+
len[2] = 13;
28+
for(int i=3;;i++) {
29+
len[i] = len[i-1] + len[i-2] + 1;
30+
K = i;
31+
if(len[i] >= N) break;
32+
}
33+
34+
br.close();
35+
}
36+
37+
public static void solve() throws Exception {
38+
bw = new BufferedWriter(new OutputStreamWriter(System.out));
39+
40+
char res = get(K, N);
41+
bw.write((res == ' ' ? "Messi Messi Gimossi" : res) + "\n");
42+
43+
bw.close();
44+
}
45+
46+
public static char get(int n, int k) {
47+
if(n == 1) return "Messi".charAt(k-1);
48+
if(n == 2) return "Messi Gimossi".charAt(k-1);
49+
if(k == len[n-1] + 1) return ' ';
50+
if(k > len[n-1]) return get(n-2, k-len[n-1]-1);
51+
return get(n-1, k);
52+
}
53+
54+
}
55+
```

0 commit comments

Comments
 (0)