- import java.util.*;
- class main{
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- while(sc.hasNext()){
- int[] N = new int[sc.nextInt()];
- for(int i =0;i<N.length;i++)
- N[i] = sc.nextInt();
- isJolly(N);
- }
- }
- static void isJolly(int[] N){
- int[] n = new int[ N.length-1];
- int i = 0 , j = 1 ,m = 0;
- while(j < N.length){
- int en = Math.abs(N[i]-N[j]);
- n[m] = en ;
- if(N.length-1 < en ||en == 0){
- System.out.println("Not jolly");
- return;
- }
- m++;
- i = j++;
- }
- for(int h = 0;h < n.length ; h++){
- for(int c = 0;c < n.length ; c++){
- if(h==c) continue;
- if(n[h]==n[c]){
- System.out.println("Not jolly");
- return;}
- }
- }
- System.out.println("Jolly");
- }
- UVA10038
:Jolly JumpersUVA10038
:Jolly Jumpers
2017年8月12日 星期六
UVA10038:Jolly Jumpers
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。