File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments