1.

/**
* Angewandte Mathematik, SS11
* Problem: 10038 Jolly Jumpers
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=979
*
* @author Unverzart Michael
* @author Wurth Manuel
* @version 1.0, 23/3/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.264
*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

public static void main(String[] args) throws Exception{

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

String inputLine;

while((inputLine = reader.readLine()) != null){

StringTokenizer st = new StringTokenizer(inputLine);

int n = new Integer(st.nextToken()) - 1;

boolean[] offset = new boolean[n];

int a = new Integer(st.nextToken());

for(int i = 0;i<n; i++){

int b = new Integer(st.nextToken());

try {
offset[Math.abs(a-b)-1] = true;
} catch (ArrayIndexOutOfBoundsException e) { /*do nothing*/ }

a=b;
}

boolean jolly = true;

for (boolean b : offset) {
if(!b) jolly = false;
}

System.out.println(jolly?"Jolly":"Not jolly");
}
}
}

2.

/**
* Angewandte Mathematik, SS11
* Problem: 10038 Jolly Jumper
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=979
*
* @author Benedikt Z¨nnchen
* @author Erik Wenzel
* @version 1.0, 03/22/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.588
*/

import java.util.Scanner;

public class Main
{

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

int count;
int[] numbers;
int number1;
int number2;
int tmp;
boolean jolly;

while (sc.hasNextLine() && sc.hasNextInt())
{
jolly = true;
String line = sc.nextLine();
Scanner secondSC = new Scanner(line);

count = secondSC.nextInt();
numbers = new int[count];
number1 = secondSC.nextInt();
number2 = 0;
tmp = 0;

int i = 1;
while (i < numbers.length && tmp < numbers.length)
{
number2 = secondSC.nextInt();
tmp = Math.abs(number1 - number2);
number1 = number2;

if (tmp >= numbers.length)
{
System.out.println("Not jolly");
jolly = false;
}
else
{
numbers[tmp] = tmp;
}
i++;
}

i = 1;
while (i < numbers.length && jolly)
{
if (numbers[i] == 0)
{
System.out.println("Not jolly");
jolly = false;
}
i++;
}
if(jolly)
{
System.out.println("Jolly");
}
secondSC.close();
}

sc.close();
}
}

3.

/**
* Angewandte Mathematik, SS11
* Problem: 10038 Jolly Jumpers
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&page=show_problem&problem=979
*
* @author Fabian Trampusch
* @author Robert Schwarz
* @version 1.0, 03/22/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 2.408 [server lief langsam zu der Zeit]
*/

import java.util.Scanner;

public class Main
{

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

while (sc.hasNextLine() && sc.hasNextInt())
{
String line = sc.nextLine();
Scanner lineScanner = new Scanner(line);
int n = lineScanner.nextInt();
if (n != 1)
{
boolean[] b = new boolean[n - 1];
boolean jolly = true;
int num1 = lineScanner.nextInt();
int num2;


while (n > 1)
{
n--;
num2 = lineScanner.nextInt();
int difference = Math.abs(num2 - num1);

if (difference > b.length
|| difference == 0
|| b[difference - 1])
{
System.out.println("Not jolly");
jolly = false;
break;
}
else
{
b[difference - 1] = true;
}

num1 = num2;
}

if (jolly)
{
System.out.println("Jolly");
}
}
else
{
System.out.println("Jolly");
}
}
}
}

4.



/**


 * Angewandte Mathematik, SS11


 * Problem: 10038 Jolly Jumpers



 *


 * @author Christopher Westerfield


 * @version 1.0, 03/20/2011


 *


 * Method : Ad-Hoc


 * Status : Accepted


 * Runtime: 0.100


 */


 

import java.util.*;


 

class Main


{


    public static void main(String args[]){


        Scanner sc = new Scanner(System.in);


        int c = sc.nextInt();


        int[] numbers = new int[c];


        for(int i = 0; i<c; i++){


            numbers[i] = sc.nextInt();


        }


        System.out.println(AreJolly(numbers));


    }


    private static String AreJolly(int[] numbers){


        for(int i=0;numbers.length>i+1;i++){


            int sequenceNumberResult = Math.abs(numbers[i] - numbers[i+1]);


            if(sequenceNumberResult == 0)


                return "Not jolly";


            if(sequenceNumberResult >= (numbers.length-i))


                return "Not jolly";


        }


        return "Jolly";


    }


}


5.

/**
* Angewandte Mathematik, SS11
* Problem: 10038 - Jolly Jumpers
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=979
*
* @author Marco Wolff
* @author Christian Weber
* @author Christoph Waldleitner
* @version 1.0, 10/23/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.304
*/

import java.io.*;

public class Main
{
public static void main(String[] args) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String aha;
while ((aha = br.readLine()) != null)
{
String[] numbers = aha.split(" ");
boolean[] jolly = new boolean[Integer.parseInt(numbers[0])];
for(int k=0;k<numbers.length-1;k++)
jolly[k]=false;
int sum=0;
if (!(numbers.length == 1 || numbers.length ==2))
{
if (Integer.parseInt(numbers[0]) > 1&&(Integer.parseInt(numbers[0]))==(numbers.length-1))
{
int a = Integer.parseInt(numbers[1]);
for (int k = 2; k < numbers.length; k++)
{
int diff = Math.abs(a- (Integer.parseInt(numbers[k])));
if (diff >= (numbers.length - 1)|| diff == 0)
{
break;
}
else
{
jolly[diff-1] = true;
}
a = (Integer.parseInt(numbers[k]));
}
for(int k=0;k<(numbers.length-2);k++)
{
if (jolly[k]==false)
{
System.out.println("Not jolly");
break;
}
else
sum++;
}
if(sum==(numbers.length-2))
System.out.println("Jolly");
} else
{
System.out.println("Not jolly");
}

}
else
System.out.println("Jolly");
}
System.exit(0);
}
}



-----------------------------------------------------------------------------------------------------
1.

package sem2.am.jollyjumpers;

/**
* Angewandte Mathematik, SS11
* Problem: 10038 - Jolly Jumpers
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=979
*
* @author Florian Stein
* @author Franz Sommer
* @version 1.0, 03/21/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.576
*/

import java.util.*;

class Main {

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

while (scanner.hasNext()) {
int rows = scanner.nextInt();
int array[] = new int[rows];
int difarray[] = new int[rows - 1];
boolean found = true;

for (int n = 0; n < array.length; n++) {
array[n] = scanner.nextInt();
}

// Differenz ausrechen und in neues Array schreiben
for (int i = 0; i < array.length - 1; i++) {
difarray[i] = Math.abs(array[i] - array[i + 1]);
}

// Array sortieren
Arrays.sort(difarray);

// Abfrage ob Differenzen > 0 und kleiner als die Anzahl der Zahlen
for (int i = 0; i < difarray.length; i++) {
if (found == true) {
if (!(difarray[i] < rows && difarray[i] > 0)) {
found = false;
}
}
// System.out.println(difarray[i]);
}

// Abfrage ob eine der Differenzen doppelt vorkommt
for (int i = 0; i < difarray.length - 1; i++) {
if (found == true)
if (difarray[i] == difarray[i + 1]) {
found = false;
}
}

// Ausgabe
if (found) {
System.out.println("Jolly");
} else {
System.out.println("Not jolly");
}
}
}
}



-----------------

1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10038 Jolly Jumper
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&page=show_problem&problem=979
*
* @author Anton Pavlushko, IBB7B,
* @version 1.0, 10/10/2010
*
* Status : Accepted
* Runtime: 0.280
*/

import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String current_line = "";
StringTokenizer input_string;
Vector check;
int n, j, difference;
int [] numbers;
boolean exits;

try {
while ((current_line=in.readLine())!= null) {
input_string = new StringTokenizer(current_line);
n = Integer.parseInt(input_string.nextToken());
if (n>0) {

numbers = new int[n+1];
check = new Vector();
exits = true;

for(j=0;(j<n && input_string.hasMoreTokens());j++) {
numbers[j+1]=Integer.parseInt(input_string.nextToken());
if (j>0) {
difference=Math.abs(numbers[j]-numbers[j+1]);
if (!check.contains(difference) && difference<n) check.add(difference);
else {
exits=false;
break;
}
}
}

if (!exits) System.out.println("Not jolly");
else if (n==1 && check.size()==0) System.out.println("Jolly");
else if (n!=1 && n-1==check.size()) System.out.println("Jolly");
else System.out.println("Not jolly");

} else System.out.println("Not jolly");
} // end while
} // end try
catch (IOException e) {
System.err.println("Error: " + e);
}
}
}