POJ 2575 Jolly Jumpers

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 16905   Accepted: 5082

Description

A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1. For instance,

1 4 2 3

is a jolly jumper, because the absolutes differences are 3, 2, and 1
respectively. The definition implies that any sequence of a single
integer is a jolly jumper. You are to write a program to determine
whether or not each of a number of sequences is a jolly jumper.

Input

Each line of input contains an integer n < 3000 followed by n integers representing the sequence.

Output

For each line of input, generate a line of output saying "Jolly" or "Not jolly".

Sample Input

4 1 4 2 3
5 1 4 2 -1 6

Sample Output

Jolly
Not jolly

CODE:
时间: 2024-10-13 23:24:13

POJ 2575 Jolly Jumpers的相关文章

POJ 2575 Jolly Jumpers(简单题)

[题意简述]:将数列中相邻的两个数做差,判断得到的绝对值是否是1,2,--,n-1,如果是的话,则是Jolly ,否则not jolly. [分析]:开始时没有仔细看题,没有看到时相邻的两个数做差,以为任意两两做差. 而后重新分析题目后,解决了这道题目,我们可以使用一个标志数组来帮助我们储存得到的做差的绝对值的值,最后,我们只需要扫描一下这个数组看是否从1,2,--,n-1都有值与之相对应. 详见代码: // 324K 47Ms #include<iostream> #include<c

E - Jolly Jumpers

E - Jolly Jumpers Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Description A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on al

UVA10038 Jolly Jumpers

Problem E: Jolly Jumpers A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1. For instance, 1 4 2 3 is a jolly jumper, because the absolutes d

POJ 2575 &amp;&amp; ZOJ 1879 Jolly Jumper(整数序列)

链接:click here 题意:对于一个包含n>0个元素的整数序列,如果序列中相邻元素之差的绝对值取边1到n-1的所有值,那么这个序列就叫做Jolly Jumper序列, 思路:水题模拟~~,不过注意*,因为不小心,wrong了几遍. 代码: #include <stdio.h> #include <string.h> #include <iostream> #include <vector> #include <iterator> #i

uva 10038 - Jolly Jumpers

1 #include <iostream> 2 #include <cstdio> 3 #include <stdlib.h> 4 using namespace std; 5 6 int seq[3001], diff[3001]; 7 8 int main() 9 { 10 int n, i, j, flag, min_index; 11 while(scanf("%d", &n) != EOF) 12 { 13 for (i = 1;

HOJ 题目分类

转自:http://blog.sina.com.cn/s/blog_65f3869301011a1o.html ******************************************************************************* 简单题(包括枚举,二分查找,(复杂)模拟,基础数据结构(栈.队列),杂题等 ****************************************************************************

计划,,留

下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinejudge.org 西班牙Valladolid大学的程序在线评测系统,是历史最悠久.最著名的OJ. 一.<算法竞赛入门经典> 刘汝佳 (UVaOJ 351道题) 以下部分内容摘自:http://sdkdacm.5d6d.com/thread-6-1-1.html "AOAPC I"

POJ-2575

/******************************************************************** @file Main_practise.cpp @date 2014-8-21 @author Tiger @brief Problem E: Jolly Jumpers ********************************************************************/ #include <cstdio> #incl

算法竞赛入门经典+挑战编程+USACO

下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发.   一.UVaOJ http://uva.onlinejudge.org  西班牙Valladolid大学的程序在线评测系统,是历史最悠久.最著名的OJ.   二.<算法竞赛入门经典> 刘汝佳  (UVaOJ  351道题)  以下部分内容摘自:http://sdkdacm.5d6d.com/thread-6-1-1.html   "AO