您的位置:首页 > 其它

poj 2575 Jolly Jumpers

2012-06-19 20:13 232 查看
//没有认真读题,WA了两次,因为他们的差值的顺序不一定需要按升序或者降序排列的!具体可以用下面的数据进行测试!
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;

int dif[3000];

int main(){
int n;
while(cin >> n){
memset(dif,0,sizeof(dif));
int pre,current;
cin >> pre;
int i;
for(i = 1; i < n; i++){
cin >> current;
int abs_dif = abs(current - pre);
dif[abs_dif] = 1;
pre = current;
}

for(i = 1; i < n; i++){
if(dif[i] == 0)
break;
}

if(i == n)
cout << "Jolly" << endl;
else
cout << "Not jolly" << endl;
}
}
/*
4 6 3 2 0
1 2
2 2 2
3 1 2 3
3 3 2 1
4 4 4 4 4
*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: