码迷,mamicode.com
首页 > 移动开发 > 详细

SDNU 1108.Happy luguans(水题)

时间:2019-06-03 21:29:01      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:icpc   print   for   input   min   mes   mic   sea   ret   

Description

A sequence of n > 0 integers is called a happy luguan 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 happy luguan, because the absolutes differences are 3, 2, and 1 respectively. The definition implies that any sequence of a single integer is a happy luguan. You are to write a program to determine whether or not each of a number of sequences is a happy luguan.

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 "Happy luguan" or "Not happy luguan".

Sample Input

4 1 4 2 3
5 1 4 2 -1 6

Sample Output

Happy luguan
Not happy luguan

Source

#include<bits/stdc++.h>
using namespace std;

int n, a[10000+8];

int main()
{
    while(~scanf("%d", &n) && n != 0)
    {
        bool flag = 1;
        for(int i = 0; i<n; i++)
            scanf("%d", &a[i]);
        for(int i = 0; i<n-1; i++)
        {
            int number = abs(a[i]-a[i+1]);
            if(number>0 && number<n)continue;
            else
            {
                flag = 0;
                break;
            }
        }
        if(flag)printf("Happy luguan\n");
        else printf("Not happy luguan\n");
    }
    return 0;
}

 

SDNU 1108.Happy luguans(水题)

标签:icpc   print   for   input   min   mes   mic   sea   ret   

原文地址:https://www.cnblogs.com/RootVount/p/10969909.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!