3
5
2015
1

UVa 10038 Jolly Jumper

#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;

int n,a[3000];
bool b[3000];
int main()
{
	while (cin>>n){
		memset(b,0,sizeof(b));
		for (int i=0;i<n;++i)
			cin>>a[i];
		for (int i=1;i<n;++i){
			int x=abs(a[i]-a[i-1]);//相邻差的绝对值
			if (x==0 || x>=n || b[x]){//若x不在范围内或前面已经有过了,
				cout<<"Not jolly"<<endl; //肯定不是jolly jumper,跳出
				goto next;
			}
			b[x]=1;
		}
		cout<<"Jolly"<<endl;//前面都没跳出,就是jolly jumper
		next:;
	}
	return 0;
}
Category: 题解 | Tags: UVa 挑战编程 模拟 | Read Count: 473

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com