2020-08-31 欢乐的跳

2020-08-31  本文已影响0人  JalorOo

https://www.luogu.com.cn/problem/P1152

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

long long qmi(int m, int k)
{
    int res = 1, t = m;
    while (k)
    {
        if (k&1) res = res * t;
        t = t * t;
        k >>= 1;
    }
    return res;
}

int read(){
    int x = 0,f = 1;
    char c = getchar();
    while (c<'0'||c>'9') {
        if (c=='-') {
            f = -1;
        }
        c = getchar();
    }
    while (c>='0'&&c<='9') {
        x = x*10+c-'0';
        c = getchar();
    }
    return x*f;
}

#define fi(a,b) for(int i = a; i <= b; i++)
#define fj(a,b) for(int j = a; j >= b; j--)

int rail[1005];
int data[1005];

int main(){
    int cnt = 0;
    int n = read();
    fi(1,n) rail[i]  = read();
    
    fi(1, n - 1){
        data[i] = fabs(rail[i+1] - rail[i]);
    }
    
    fi(1, n)fj(n - 1, i) if(data[j+1]<data[j]){ swap(data[j+1],data[j]);}
    
    int a = 1;
    fi(2,n - 1){
        if(data[i] != a){
            cout<<"Not jolly"<<endl;
            return 0;
        }
        a++;
    }
    cout<<"Jolly"<<endl;
    return 0;
}
/*
4 1 4 2 3
============
6
*/

上一篇下一篇

猜你喜欢

热点阅读