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 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

难懂的题意。。(被题意坑了一发QAQ)

首先输入一个正整数n,后接n个数字,每连续的两个数字相减的绝对值组成1~n-1共n-1个数字。

AC代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std; const int MAX=;
int a[MAX];
int b[MAX];
int n;
int main(){
while(~scanf("%d",&n)){
for(int i=;i<n;i++){
scanf("%d",&a[i]);
}
if(n==){//当n为1时直接输出
printf("Jolly\n");
continue;
}
for(int i=;i<n;i++){//两两相减的绝对值
b[i]=abs(a[i]-a[i-]);
}
int temp;
for(int i=;i<n;i++){//冒泡排序
for(int j=n-;j>=i;j--){
if(b[j]<b[j-]){
temp=b[j];
b[j]=b[j-];
b[j-]=temp;
}
}
}
int ans=;
for(int i=;i<n;i++){//记录相等数字数
if(b[i]==i)
ans++;
}
if(ans==n-)
printf("Jolly\n");
else
printf("Not jolly\n");
}
return ;
}

E - Jolly Jumpers的更多相关文章

  1. 烟大 Contest1025 - 《挑战编程》第二章:数据结构 Problem A: Jolly Jumpers(水题)

    Problem A: Jolly Jumpers Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 10  Solved: 4[Submit][Status] ...

  2. uva 10038 - Jolly Jumpers

    #include <iostream> #include <cstdio> #include <stdlib.h> using namespace std; ], ...

  3. Zerojudge解题经验交流

    题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识 ...

  4. OpenJudge解题经验交流

    1.1编程基础之输入输出01:Hello, World! 02:输出第二个整数PS:a,b需用longint类型接收 03:对齐输出 04:输出保留3位小数的浮点数 05:输出保留12位小数的浮点数 ...

  5. (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO

    http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...

  6. ACM训练计划step 1 [非原创]

    (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...

  7. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

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

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  9. C语言中函数声明实现的位置

    在学习C语言的时候我遇到了这么个事情,因为之前先学习的C#,在C#编译器中,函数的声明位置不会影响编译的结果,但是在C语言中却发生了错误 先看一段代码: #include <stdio.h> ...

随机推荐

  1. 云舒网络译:Rancher1.0正式版公布

    编者注: Rancher Labs是一家容器技术基础设施提供商,总部位于美国硅谷,Rancher是一个高效易用的企业容器云平台. 云舒网络 http://www.cloudsoar.com/为Ranc ...

  2. hdu5387(2015多校8)--Clock(模拟)

    题目链接:点击打开链接 题目大意:给出一个时间,问在钟表上这个时间的时候.时针和分针的角度,时针和秒针的角度.分针和秒针的角度.假设不是整数以分数的形式输出. 假设依照最小的格来算,那么: 1s对于秒 ...

  3. 快速上手npm

    1.npm的安装和更新 2.npm的常用操作 3.npm的常用配置项 4.npm常用命令速查表

  4. Quartz 2D编程指南(2)图形上下文(Graphics Contexts)

    Graphics Contexts       一个Graphics Context表示一个绘制目标(也能够理解为图形上下文).它包括绘制系统用于完毕绘制指令的绘制參数和设备相关信息.Graphics ...

  5. nanoporetech/nanonet

    nanoporetech/nanonet CodeIssues 7Pull requests 0Projects 0Wiki Insights  First generation RNN baseca ...

  6. wmware搬家

    由于D盘空间不足D:\Users\Documents\Virtual Machines文件夹剪切至E:\Virtual Machines. 先关闭虚拟机 然后剪切 直接通过icon无法打开 先运行E: ...

  7. PythonCookBook笔记——迭代器与生成器

    迭代器与生成器 迭代是Python最强大的功能之一,虽然看起来迭代只是处理序列中元素的一种方法,但不仅仅如此. 手动遍历迭代器 想遍历但不想使用for循环. 使用next()方法并在代码中捕获Stop ...

  8. WPF前台数据验证(红框)Validation.ErrorTemplate 附加属性

    WPF 显示验证错误的默认方式是在控件周围绘制红色边框.通常需要对此方法进行自定义,以通过其他方式来显示错误.而且,默认情况下不会显示与验证错误关联的错误消息.常见的要求是仅当存在验证错误时才在工具提 ...

  9. iOS开发中的单元测试(三)——URLManager中的测试用例解析

    本文转载至 http://www.cocoachina.com/cms/plus/view.php?aid=8088   此前,我们在<iOS开发中的单元测试(一)&(二)>中介绍 ...

  10. 理解c/c++指针和引用

    1 指针的指针 比如int* a,那么a是指向一个int型的对象的.也就是说,*前面的类型是该指针指向的对象的类型. 同理int** a的话,a指向一个int*型的对象,也就是说,它指向的对象也是一个 ...