首页 > 代码库 > POJ-2575

POJ-2575

/********************************************************************@file     Main_practise.cpp@date     2014-8-21@author   Tiger@brief    Problem E: Jolly Jumpers********************************************************************/#include <cstdio>#include <cstring>#define SIZE 3000+1//#define OJbool FLag[SIZE];int  Arr[SIZE];int main(int argc, const char* argv[]){#ifdef OJ    freopen("input.txt", "r", stdin);#endif    int nCnt = 0;    while (scanf("%d", &nCnt) != EOF)    {        for (int i=0; i<nCnt; ++i)        {            scanf("%d", &Arr[i]);        }        bool bResult = true;        int  nResult = 0;        memset(FLag, false, SIZE);        for (int i=0; i<nCnt-1; ++i)        {            nResult = Arr[i+1] - Arr[i];            nResult = nResult > 0 ? nResult : -nResult;            if (nResult > nCnt-1 || 0 == nResult || true == FLag[nResult])            {                bResult = false;                break;            }            else            {                FLag[nResult] = true;            }        }        for (int i=1; i<nCnt-1; ++i)        {            if (false == FLag[i])            {                bResult = false;                break;            }        }        if (bResult)        {            printf("Jolly\n");        }        else        {            printf("Not jolly\n");        }    }    return 0;}