UVA10038 Jolly Jumpers
来源:互联网 发布:淘宝的伞黑胶都在外面 编辑:程序博客网 时间:2024/05/20 22:27
Problem E: Jolly Jumpers
1 4 2 3is 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 35 1 4 2 -1 6
Sample Output
JollyNot jolly
题意是要相邻的两个数的绝对值在[1,n),而且这个范围内的每个数都要出现一次。
#include <stdio.h>#include <string.h>#include <stdlib.h>int vis[3002];int main(){int n, a, b, ok, t, m;while(scanf("%d", &n) != EOF){scanf("%d", &a);m = n; ok = 1;memset(vis, 0, sizeof(vis));while(--n){scanf("%d", &b);if(ok == 0) continue;if((t = abs(a - b)) == 0 || t >= m || vis[t])ok = 0; a = b; vis[t] = 1;}printf(ok ? "Jolly\n" : "Not jolly\n");}return 0;}
0 0
- uva10038 Jolly Jumpers
- UVA10038 Jolly Jumpers
- UVA10038 - Jolly Jumpers
- Jolly Jumpers
- jolly jumpers
- fjnu 1532 Jolly Jumpers
- fjnu 1591 Jolly Jumpers
- 1591Jolly Jumpers
- POJ2575 Jolly Jumpers
- UVa 10038 Jolly Jumpers
- poj 2575 Jolly Jumpers
- zoj 1879 Jolly Jumpers
- poj 2575 Jolly Jumpers
- ZOJ 1879 Jolly Jumpers
- 10038 - Jolly Jumpers
- UVa 10038 - Jolly Jumpers
- zoj 1879 Jolly Jumpers
- ZOJ 1879 Jolly Jumpers
- JavaWeb项目登录Session失效问题
- linux下的打包和压缩
- HDU 1174 3维点到直线距离
- java web进阶篇(五) JSP标准标签库 ** 核心标签***
- STC单片机 定时器时钟FOSC 1T 12T、定时器模式
- UVA10038 Jolly Jumpers
- Jquery Mobile 插件 iscroll的使用
- Struts2教程4:使用validate方法验证数据
- Linux下C语言学习(二)——流程控制语句和数组的学习
- 确定进制(经典水题)
- 垃圾回收(garbage collection)介绍
- 直接路由的高可用LVS集群配置
- 程序员必须知道的10大基础实用算法及其讲解
- OpenCV的序列数据结构