import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
String m;
int cases = 1;
while ((m = br.readLine()) != null) {
int[] arr = new int[Integer.parseInt(m)];
StringTokenizer st = new StringTokenizer(br.readLine());
HashSet<Integer> hs = new HashSet<Integer>();
for (int i = 0; i < arr.length; i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
boolean flag = false;
if (arr[0] < 1) {
flag = true;
}
if (flag) {
sb.append("Case #").append(cases).append(": It is not a B2-Sequence.\n\n");
cases++;
br.readLine();
continue;
}
for (int i = 0; i < arr.length - 1; i++) {
if (arr[i] >= arr[i + 1]) {
flag = true;
break;
}
}
if (flag) {
sb.append("Case #").append(cases).append(": It is not a B2-Sequence.\n\n");
cases++;
br.readLine();
continue;
}
for (int i = 0; i < arr.length; i++) {
for (int j = i ; j < arr.length; j++) {
int temp = arr[i] + arr[j];
if (hs.contains(temp)) {
flag = true;
break;
}
hs.add(temp);
}
if (flag) {
break;
}
}
if (flag) {
sb.append("Case #").append(cases).append(": It is not a B2-Sequence.\n\n");
cases++;
} else {
sb.append("Case #").append(cases).append(": It is a B2-Sequence.\n\n");
cases++;
}
br.readLine();
}
System.out.print(sb);
}
}
No comments:
Post a Comment