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. python去除停用词(结巴分词下)

    python 去除停用词  结巴分词 import jieba #stopwords = {}.fromkeys([ line.rstrip() for line in open('stopword. ...

  2. 【软件创意】智能Goals (android)

    智能Goals  软件创意核心思想:实现你的愿望. 功能概要:帮助记录奋斗了的历程.实现你的愿望.可以是跑步减肥,每天阅读,交际,存钱买房.满足各种记录需要,目标可以是完成多长时间,可以用计时器:可以 ...

  3. SD 卡PIN定义

    转载:http://blog.sina.com.cn/s/blog_56e19aa70101avnw.html SD卡和TF卡接口引脚定义  

  4. linux查看磁盘信息

    linux查看磁盘挂载信息:df -hlinux查看文件夹大小:sudo du -h --max-depth=1

  5. codeforces 557 C

    由于期末.非常久没刷题了,CF一直掉-- 这个题事实上非常简单. .由于做法非常easy想到嘛.. 就是枚举max=x时,最大能保留多少价值.不断更新ans, 结果就是全部价值和减去ans就好 因为最 ...

  6. jQuery功能强大的图片查看器插件

    简要教程 viewer是一款功能强大的图片查看器jQuery插件.它可以实现ACDsee等看图软件的部分功能.它可以对图片进行移动,缩放,旋转,翻转,可以前后浏览一组图片.该图片查看器还支持移动设备, ...

  7. Xcode 6 的新增特性

    本文转载至 http://www.cocoachina.com/ios/20140823/9441.html (via:苹果开发者中心)   Xcode 6 引入了设计和构建软件的崭新方式.Swift ...

  8. Unable to run Kiwi tests on iOS8 device

    本文转载至 http://stackoverflow.com/questions/25871601/unable-to-run-kiwi-tests-on-ios8-device 5down vote ...

  9. 【BZOJ1419】Red is good 期望

    [BZOJ1419]Red is good Description 桌面上有R张红牌和B张黑牌,随机打乱顺序后放在桌面上,开始一张一张地翻牌,翻到红牌得到1美元,黑牌则付出1美元.可以随时停止翻牌,在 ...

  10. photoswipe 实现图片的单击放大

    1.项目结构 2.HTML 代码 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind=&qu ...