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

用set还是很方便的。给大家参考下

Posted by Aiscanf at 2009-04-22 11:13:26 on Problem 2575
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
	int index[3001]={0};
	int total_num;
	while(scanf("%d",&total_num)==1)
	{
		int temp;
		set<int>result;
		for (int i = 0 ;i<total_num;++i)
		{
			scanf("%d",&temp);
			index[i]=temp;
			if (i!=0)
			{
				temp=(index[i]-index[i-1])>0?(index[i]-index[i-1]):(index[i-1]-index[i]);
				if(temp>0&&temp<total_num)
					result.insert(temp);
			}
		}
		if(result.size()==total_num-1)
			printf("Jolly\n");
		else
			printf("Not jolly\n");
	}
	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