Programming contests

ACM ICPC programozó csapatverseny, házi forduló, 2015. október 21.

October 21, 2015 10:00 AM – October 21, 2015 3:00 PM

A-Sequence

For this problem, an A-sequence is a sequence of positive integers ai satisfying 1 ≤ a1 < a2 < a3 < …, and every ak of the sequence is not the sum of two or more distinct earlier terms of the sequence.

You should write a program to determine whether a given sequence is or is not an A-sequence.

Input Specification

The input consists of a set of lines. Each line starts with an integer 2 ≤ D ≤ 30 indicating the number of integers contained in the current sequence. Following this number, there is the sequence itself. The sequence is composed of integers; each integer is greater than or equal to 1 and less than or equal to 1000. The input is terminated by end of file (EOF).

Output Specification

For each test case in the input, you should print two lines: the first line should indicate the number of the test case and the test case itself; in the the second line, you should print “This is an A-sequence.” if the corresponding test case is an A-sequence or “This is not an A-sequence.” if the corresponding test case is not an A-sequence.

Sample Input

  1. 2 1 2
  2. 3 1 2 3
  3. 10 1 3 16 19 25 70 100 243 245 306
download as text file

Output for Sample Input

  1. Case #1: 1 2
  2. This is an A-sequence.
  3. Case #2: 1 2 3
  4. This is not an A-sequence.
  5. Case #3: 1 3 16 19 25 70 100 243 245 306
  6. This is not an A-sequence.
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019