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

没那么麻烦吧,看看我的代码

Posted by 20083331 at 2009-04-30 18:46:49 on Problem 2575
#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