1.

package contestVolumes.volume109;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;
/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10930 - A-Sequence
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=21&page=show_problem&problem=1871
*
* @author Siegfried Ippisch
* @version 1.0
*
* Method : -
* Status : Accepted
* Runtime: 0.240
*/
public class ASequence {

public static void main(String[] args){
Scanner in = new Scanner(System.in);
int c = 1;

while(in.hasNext()){
int n = in.nextInt();
LinkedList<Integer> list = new LinkedList<Integer>();
for(int i=0; i<n; i++)
list.add(in.nextInt());

System.out.println("Case #"+ c++ +":"+listToString(list));
System.out.println(aSequence(list) ? "This is an A-sequence.": "This is not an A-sequence.");
}

in.close();
}

private static String listToString(LinkedList<Integer> list) {
String s = "";
for(int i: list)
s = s + " " + i;
return s;
}
 public static boolean aSequence(LinkedList<Integer> list){
Set<Integer> sum = new HashSet<Integer>();
sum.add(list.removeFirst());

int last = 0;
while(!list.isEmpty()){
int a = list.removeFirst();

if(a <= last)
return false;

if(sum.contains(a))
return false;

last = a;

LinkedList<Integer> newSums = new LinkedList<Integer>();
for(int s: sum)
newSums.add(s+a);

sum.add(a);
sum.addAll(newSums);
}

return true;
}
}


2.

package acm_10930_a_sequence;


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Scanner;

/**
* FWP, Ausgew¦hlte Probleme aus dem ACM Programming Contest, SS10
* Problem: acm_10930_a_sequence
* Link:
*
* @author Martin Lambeck
* @version 1.0, 25.08.2010
*
* Method :
* Status : Accepted
* Runtime:
*/


public class Main
{
static Scanner sc = new Scanner(System.in);
static int tcase = 0;

public static void main(String... args)
{
while (testcase())
;
}

public static boolean testcase()
{
if (!sc.hasNextInt())
return false;

int count = sc.nextInt();

ArrayList<Integer> seq = new ArrayList<Integer>(count);
boolean[] sum = new boolean[1001];
LinkedList<Integer> lsum = new LinkedList<Integer>();

StringBuilder str = new StringBuilder("");
boolean fail = false;
int prev = 0;

for (int i = 0; i < count; i++)
{
int n = sc.nextInt();

if (prev >= n)
fail = true;

seq.add(n);
str.append(" " + n);
prev = n;
}


if (!fail)
for (int s : seq)
{
if (sum[s])
{
fail = true;
break;
}

ListIterator<Integer> itr = lsum.listIterator();

while (itr.hasNext())
{
int sl = s + itr.next();

if ((sl <= 1000) && !sum[sl])
{
sum[sl] = true;
itr.add(sl);
}
}

lsum.add(s);
}

tcase++;


System.out.printf("Case #%d:%s%nThis is %s A-sequence.%n", tcase, str, (fail ? "not an" : "an"));

return true;
}
}