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 |
import java.util.Arrays; import java.util.Scanner; /** * UVA11063 */ public class UVA11063 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int count = 0; while (sc.hasNext()) { String str = sc.next(); if (str.equals("EOF")) break; count++; int n = Integer.parseInt(str); int[] num = new int[n]; for (int i = 0; i < n; i++) num[i] = sc.nextInt(); boolean flag = true; for (int i = 0; i < num.length - 1; i++) { int sum = num[i] + num[i + 1]; for (int j = 0; j < num.length; j++) if (sum == num[j]) { flag = false; break; } if (flag == false) break; } System.out.printf("Case #%d: It is%s a B2-Sequence.\r\n", count, flag ? "" : " not"); } sc.close(); } } |