1.

/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #11063 (B2-Sequence)
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=problem_stats&problemid=2004&category=22
*
* @author Christian Posselt
* @author Jonathan Schubert
* @author Doina Logofatu
* @version 1.2, 05/11/2009
*
* Status : Accepted
* Runtime: 0.156
*/

import java.io.*;
import java.util.*;

class Main
{
public static void main(String[] args) throws IOException
{
StringBuilder builder = new StringBuilder();
Scanner sc = new Scanner(System.in);
int casecounter = 1;
while(sc.hasNext())
{
int amount = sc.nextInt();
int[] serie = new int[amount];
HashSet<Integer> diffs = new HashSet<Integer>();

boolean flag = true;

//read first digit of serie
if(sc.hasNext() && amount > 0)
{
int next = sc.nextInt();
if(next > 0)
serie[0] = next;
else
flag = false;
}

//read the hole series. As if you found an error you have to read the all the digits left
for( int i = 1; i < amount && sc.hasNext(); i++)
{
serie[i] = sc.nextInt();
if(serie[i-1] >= serie[i])
flag = false;
}
//calculate sums and put them in an ArrayList
for( int outerIndex = 0; outerIndex < amount - 1 && flag; outerIndex ++)
{
for( int innerIndex = outerIndex; innerIndex < amount && flag; innerIndex++ )
{
int summ = serie[innerIndex]+serie[outerIndex];
if(diffs.contains(summ))
flag = false;
diffs.add(summ);
}
}
if(flag)
builder.append("Case #"+casecounter+": It is a B2-Sequence.\n\n");
else
builder.append("Case #"+casecounter+": It is not a B2-Sequence.\n\n");
casecounter ++;
}
//builder.deleteCharAt(builder.length()-1);
System.out.print(builder.toString());
}
}



2.


/**
* Angewandte Mathematik SS 09
11063 B2 Sequence
* UVa Status: Acepted
* Run Time: 0.010
* Programming Language: C
* @author Doina Logofatu logofatu@hm.edu
*/

#include <stdio.h>

#define STR_IS "Case #%d: It is a B2-Sequence.\n\n"
#define STR_NOT "Case #%d: It is not a B2-Sequence.\n\n"

int main(){

int n, i, j, k, l, a[100];
int counter=0, found;

while (scanf("%d", &n)==1)
{

scanf("%d", a);

found=0;
if(a[0]<1) {printf(STR_NOT, ++counter); found=1;};

for(i=1; i<n; i++){
scanf("%d", a+i);
if(!found && a[i]<=a[i-1]) {printf(STR_NOT, ++counter); found=1;};
}

if(found) continue;

for(i=0; !found && i<n-1; i++){

for(j=i; !found && j<n; j++)
for(k=0; !found && k<n-1; k++)
for(l=k; !found && l<n; l++)
if(a[i]+a[j]==a[k]+a[l]&&(i-k||j-l)) found=1;
}

if(found) printf(STR_NOT, ++counter);
else printf(STR_IS, ++counter);

}
return 0;
}

3.

/**
* Angewandte Mathematik SS 09
11063 B2 Sequence
* UVa Status: Acepted
* Run Time: 0.010
* Programming Language: C
* @author Doina Logofatu logofatu@hm.edu
*/

#include <stdio.h>
#include <math.h>

int main(){

int n, i, j, k, l, a[100];
int counter=0, found;

while (scanf("%d", &n)==1)
{
counter++;

for(i=0; i<n; i++)
scanf("%d", a+i);

found = a[0]>=1?0:1;
for(i=0; !found && i<n-1; i++){
if(a[i]>=a[i+1]) found=1;
for(j=i; !found && j<n; j++)
for(k=0; !found && k<n-1; k++)
for(l=k; !found && l<n; l++)
if(a[i]+a[j]==a[k]+a[l]&&(i-k||j-l)) found=1;
}

printf("Case #%d: It is ", counter);
if(found) printf("not ");
printf("a B2-Sequence.\n\n");

}
return 0;
}