1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import java.util.Arrays; import java.util.Scanner; /** * UVA10038 */ public class UVA10038 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextLine()) { int time = sc.nextInt(); int[] intArray = new int[time]; for (int i = 0; i < intArray.length; i++) intArray[i] = sc.nextInt(); int[] d = new int[intArray.length - 1]; for (int i = 0; i < d.length; i++) d[i] = Math.abs(intArray[i] - intArray[i + 1]); Arrays.sort(d); boolean flag = true; for (int i = 0; i < time - 1; i++) if (d[i] != i + 1) flag = false; System.out.printf("%s\r\n", flag ? "Jolly" : "Not jolly"); } sc.close(); } } |