1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, 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 Beinhofer Christian
* @version 1.0, 24.03.2011
*
* Method : ad hoc
* Status : Accepted
* Runtime: 0.008
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

bool GetNextInteger(int & value)
{
bool neg = false;
int ch;

// get sign and first char of the number
while((ch = getchar()) != EOF)
if(ch == '-') neg = true;
else if(ch >= '0' && ch <= '9')
break;

if(ch == EOF) return false;

value = 0;
do {
value *= 10;
value += ch - '0';
} while(((ch = getchar()) != EOF) && (ch >= '0' && ch <= '9'));

if(neg) value = -value;

return true;
}

int main(int argc, char* argv[])
{
int count = 0, value, lastvalue;

int * diffs = (int*)malloc(sizeof(int) * 3000);

while(GetNextInteger(count))
{
memset(diffs, 0, sizeof(int) * (count - 1));

GetNextInteger(lastvalue);

for(int i = 0; i < count - 1; i++)
{
GetNextInteger(value);

int diff = abs(lastvalue - value) - 1;

if((diff < 0 || diff >= count - 1) || diffs[diff] == 1)
{
for(i++; i < count - 1; i++)
GetNextInteger(value);

goto NOJOLLY;
}

diffs[diff] = 1;

lastvalue = value;
}

for(int i = 0; i < count - 1; i++)
if(diffs[i] == 0)
goto NOJOLLY;

puts("Jolly");
continue;

NOJOLLY:
puts("Not jolly");
}

free(diffs);

return 0;
}

2.

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

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, 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 Bastian Hoecker
* @author Philipp Hauck Thalheim
* @version 1.0, 03/30/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.264
*/
public class Main {

/**
* @param args
*/
public static void main(String[] args) throws IOException {

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

while (br.ready()) {

StringTokenizer st = new StringTokenizer(br.readLine());

int n = Integer.parseInt(st.nextToken());
int diff = n - 1;
boolean[] flag = new boolean[diff];
int count = 0;
int zwerg = Integer.parseInt(st.nextToken());

while (st.hasMoreTokens()) {
int zwerg2 = Integer.parseInt(st.nextToken());
int absDiff = Math.abs(zwerg2 - zwerg);
if (absDiff > diff || absDiff < 1) {


break;
} else {

flag[absDiff - 1] = true;
}
zwerg = zwerg2;

}
for (int i = 0; i < flag.length; i++) {
if (flag[i] != true) {
System.out.println("Not jolly");
break;
}
count++;
}

if (count == flag.length) {
System.out.println("Jolly");
}

}

}

}

3.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 10038 Jolly Jumper
* Link: http://bbs.cooldavid.org/acm/v100/10038.html
*
* @author Weigl Joseph
* @author Müller Thomas
* @version 1.0, 03/30/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.264
*/


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


public class Main {

public static void main(String... args) throws IOException{
int n;
int a;
int b;
int diff;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while(reader.ready()){
StringTokenizer token = new StringTokenizer(reader.readLine());
n = Integer.parseInt(token.nextToken());
boolean[] jj = new boolean[n-1];;
//boolean jolly = false;
a = Integer.parseInt(token.nextToken());
while(token.hasMoreTokens()){
b = Integer.parseInt(token.nextToken());
diff = Math.abs(a-b);
if(diff < n && diff > 0)
jj[diff-1] = true;
a = b;
}


int count = 0;
for(boolean j : jj){
if(j)
count++;
}
if(count == jj.length)
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);
}
}
}