Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

实在看不出怎么WA

Posted by emperorlu at 2008-01-15 15:26:04 on Problem 2575
#include<iostream>
using namespace std;
int a[3010];
bool b[3010];
int main()
{
    int n,ab,tmp;
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            b[i]=0;
        }
        if(n==1)
        {
            cout<<"Jolly"<<endl;
            continue;
        }
                
        for(int i=0;i<n-1;i++)
        {
            tmp=a[i]-a[i+1];
            ab=tmp>0?tmp:-tmp;
            if(ab>0&&ab<n)b[ab]=1;
        }
        int flag=0;
        for(int i=1;i<n;i++)
        {
            if(!b[ab])
            {
                flag=1;
                break;
            }
        }
        if(flag)cout<<"Not jolly"<<endl;
        else cout<<"Jolly"<<endl;
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator