uva :: Programming Challenges :: Chapter 2

 1 /* 
 2  * File:   10038.cpp
 3  * Author: GongZhi
 4  * Problem: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=30&page=show_problem&problem=979
 5  * Created on 2009年7月27日, 上午1:10
 6  */
 7 
 8 #include <stdlib.h>
 9 #include <string.h>
10 #include <iostream>
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <queue>
15 using namespace std;
16 
17 /*
18  *
19  */
20 int a[4000];
21 char mark[4000];
22 
23 int main() {
24     int n, i, t, f;
25     while (scanf("%d"&n) != EOF) {
26         f = 1;
27         for (i = 0; i < n; i++)scanf("%d"&a[i]);
28         memset(mark, 0sizeof (mark));
29         for (i = 1; i < n; i++) {
30             t = a[i] - a[i - 1];
31             if (t < 0)t = -t;
32             if (t >= n)f = 0;
33             if (!f)break;
34             if(mark[t])f=0;
35             mark[t]=1;
36             if (!f)break;
37         }
38         if(f)printf("Jolly\n");
39         else printf("Not jolly\n");
40     }
41     return 0;
42 }
43 
44 

posted on 2009-07-27 01:17 gong 阅读(1077) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2009年7月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿(6)

随笔档案

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜