Problem A: Jolly Jumpers

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 10  Solved: 4
[Submit][Status][Web Board]

Description

A sequence of n > 0 integers is called a jolly jumper if the absolute values of the differences between successive elements take on all possible values 1 through n - 1. For instance, 1 4 2 3 is a jolly jumper, because the absolute differences are 3, 2, and 1, respectively. The definition implies that any sequence of a single integer is a jolly jumper. Write a program to determine whether each of a number of sequences is a jolly jumper.

Input

Each line of input contains an integer n < 3, 000 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

    - 

Sample Output

Jolly
Not jolly

HINT

poj2575


  水题。

  这道题要求输入一串整型数,第一个数为n,后面接着有n个int数,要求后面这n个数两两之间差的绝对值在[1,n-1]范围内,且差的绝对值不能重复。

  虽是水题,但还是纠结了一会,原因还是没有读懂题意,忽略了第二个条件。由此可见,英语阅读能力的重要性!

My code:

 #include <iostream>

 using namespace std;

 int abs(int n)
{
return n>?n:-n;
}
int main()
{
int n;
int ab;
int i;
int a[];
while(cin>>n){
bool b[]={}; //记录绝对值差有无重复
for(i=;i<n;i++){ //输入
cin>>a[i];
}
for(i=;i<n;i++){ //循环判断
int t=abs(a[i]-a[i-]);
if(!(<=t && t<=n-) || b[t] )
break;
else{
b[t]=true;
}
}
if(i==n) //如果正常跳出,说明是个Jolly
cout<<"Jolly"<<endl;
else{
cout<<"Not jolly"<<endl;
}
}
return ;
}

Freecode : www.cnblogs.com/yym2013

烟大 Contest1025 - 《挑战编程》第二章:数据结构 Problem A: Jolly Jumpers(水题)的更多相关文章

  1. [转]Windows Shell 编程 第二章 【来源:http://blog.csdn.net/wangqiulin123456/article/details/7987893】

    第二章Shell的结构  “Shell 编程”的大伞之下有大量的API函数和COM接口.这个种类繁多的‘命令’集允许你用不同的方法对Windows Shell进行编程.函数和接口并不是两种提供相同功能 ...

  2. java面向对象编程——第二章 java基础语法

    第二章 java基础语法 1. java关键字 abstract boolean break byte case catch char class const continue default do ...

  3. 使用MYSQL数据库实现编程----第二章第三章课堂知识小总结

    第二章1:创建数据库create database myschool 2.数据类型  1.整型 int  2.小数 double  精确度要求高的 ----Decimal(18,4)  2222222 ...

  4. windows核心编程---第二章 字符和字符串处理

        使用vc编程时项目-->属性-->常规栏下我们可以设置项目字符集合,它可以是ANSI(多字节)字符集,也可以是unicode字符集.一般情况下说Unicode都是指UTF-16.也 ...

  5. 读高性能JavaScript编程 第二章 让我知道了代码为什么要这样写

    代码为什么要这样写? function initUI(){ var doc = document, bd = doc.body, links = doc.getElementsByTagName_r( ...

  6. windows核心编程-第二章 Unicode

    第2章U n i c o d e 随着M i c r o s o f t公司的Wi n d o w s操作系统在全世界日益广泛的流行,对于软件开发人员来说,将目标瞄准国际上的各个不同市场,已经成为一个 ...

  7. Java面向对象编程 第二章 第一个Java应用

    2.1创建Java源文件 Java应用由一个或多个扩展名为".java"的文件构成,这些文件被称为Java源文件,从编译的角度,则被称为编译单元. 本章包含两个Java源文件:Do ...

  8. JAVA / MySql 编程——第二章 初始MySQL

    1. MySQL:        ●  MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司.            MySQL最流行的关系型数据库管理系统, ...

  9. 【学习总结】java数据结构和算法-第二章-数据结构和算法概述

    总目录链接 [学习总结]尚硅谷2019java数据结构和算法 github:javaDSA 目录 数据结构和算法的关系 几个实际编程中的问题 线性结构和非线性结构 数据结构和算法的关系 几个实际编程中 ...

随机推荐

  1. Extreme Learning Machine(ELM)的工程哲学

    Extreme Learning Machine(ELM)的工程哲学 David_Wang2015 发布于2015年5月6日 11:29 工程问题往往需要的是一定精度范围内的结果,而不是“真正的”结果 ...

  2. ASP.NET MVC4中使用Ninject

    1.NuGet获取Ninject.dll 选中项目右键: .NET技术交流群 199281001 .欢迎加入. 2.全局注册  Global.asax.cs //注册Ninject依赖注入全局解析器 ...

  3. WPF 获取IP地址

    List<string> ipList = new List<string>(); foreach (IPAddress _IPAddress in Dns.GetHostEn ...

  4. WPF获取鼠标当前位置

    /// <summary> /// 设置鼠标的坐标 /// </summary> /// <param name="x">横坐标</par ...

  5. motto5

    No matter what others say,I won't forsake my priciples.

  6. 【Swoole应用教程】一、Swoole扩展的编译安装部署

    介绍swoole扩展,从源码的下载,环境依赖,编译参数配置,常见编译问题,安装,配置等内容.期间还会介绍: Linux发行版本的选择 不同版本内核的差异 gcc/g++/clang 3种编译器介绍 a ...

  7. 如何实现在已有代码之后添加逻辑之java动态代理

    在上篇博客中讨论到java的静态代理, 就是通过组合的方法,前提是委托类需要实现一个接口,代理类也实现这个这个 接口,从何组合两个类,让代理类给委托类添加功能! 知道java的静态代理,我们又遇到一个 ...

  8. [codeforces 325]B. Stadium and Games

    [codeforces 325]B. Stadium and Games 试题描述 Daniel is organizing a football tournament. He has come up ...

  9. haartraining生成.xml过程

    继续向大神学习http://www.cnblogs.com/tornadomeet/archive/2012/03/28/2420936.html

  10. 坚持不懈之linux haproxy 配置文件 详情

    ####################全局配置信息######################## #######参数是进程级的,通常和操作系统(OS)相关######### global maxc ...