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

Re:高手帮忙帮改下啊 麻烦

Posted by 550642630 at 2009-08-25 14:26:15 on Problem 2575
In Reply To:高手帮忙 Posted by:123WANGSONG at 2009-08-10 17:09:57
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
	int record[3005];
	int absolute[3005];
	int n;
	while(cin>>n)
	{
		cin>>record[0];
		for(int i=1;i<n;i++)
		{
			cin>>record[i];
			absolute[i-1]=abs(record[i]-record[i-1]);
		}
		sort(absolute,absolute+n-1);
//		cout<<"absolute[n-2]"<<absolute[n-2]<<"  n-1  is  "<<n-1<<endl;
		int flag=0;
		for(int j=0;j<=n-2;j++)
		{
			if(absolute[j]!=j+1)
			{
				cout<<"Not jolly"<<endl;
				flag=1;
				break;
			}
		}
		if(flag==0)
			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