Skip to content

Commit c6fee3c

Browse files
authored
[20251028] BOJ / G3 / IQ Test / 김수연
[20251028] BOJ / G3 / IQ Test / 김수연
2 parents 91c87a6 + f1eb1c7 commit c6fee3c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class boj1111 {
6+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
static StringTokenizer st;
8+
static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());}
9+
static int nextInt() {return Integer.parseInt(st.nextToken());}
10+
11+
public static void main(String[] args) throws Exception {
12+
nextLine();
13+
int N = nextInt();
14+
nextLine();
15+
int[] num = new int[N];
16+
for (int i = 0; i < N; i++) num[i] = nextInt();
17+
if (N == 1) {
18+
System.out.println("A");
19+
return;
20+
} else if (N == 2) {
21+
if (num[0] == num[1]) System.out.println(num[0]);
22+
else System.out.println("A");
23+
return;
24+
}
25+
int a = (num[1] != num[0]) ? (num[2] - num[1]) / (num[1] - num[0]) : 0;
26+
int b = num[1] - num[0] * a;
27+
28+
for (int i = 1; i < N-1; i++) {
29+
if (num[i] * a + b != num[i+1]) {
30+
System.out.println("B");
31+
return;
32+
}
33+
}
34+
System.out.println(num[N-1] * a + b);
35+
}
36+
}
37+
```

0 commit comments

Comments
 (0)