-
Notifications
You must be signed in to change notification settings - Fork 0
/
MCOINS.java
38 lines (34 loc) · 905 Bytes
/
MCOINS.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.company;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int k = in.nextInt();
int l = in.nextInt();
int m = in.nextInt();
String str = "";
char[] arr = new char[1000001];
arr[0] = 'B';
arr[1] = 'A';
for (int i= 2; i<1000001; i++) {
if (arr[i-1] =='B') {
arr[i] = 'A';
}
else if ((i-l>=0) && (arr[i-l] == 'B')) {
arr[i] ='A';
}
else if((i-k>=0) && (arr[i-k]=='B')) {
arr[i]='A';
}
else{
arr[i]='B';
}
}
for (int i = 0; i<m; i++) {
int tmp = in.nextInt();
str += arr[tmp];
}
System.out.println(str);
in.close();
}
}