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

为什么总是不能ACC, 恳请高手相助:

Posted by catsky at 2006-10-05 11:28:27 on Problem 2575
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
using namespace std;

bool Judge(vector<int> &vec)
{   int i;
	for( i = 0; i < vec.size()-1; i++)
	{
		vec.at(i) = abs(vec.at(i)-vec.at(i+1));
	}
	sort(vec.begin(), vec.end());
	for(i = 0; i < vec.size()-1; i++)
	{
		if(vec.at(i) != i+1)
			return false;
	}
	return true;

}
void Problem(vector<int> &vec)
{
	int n;
	int dat;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &dat);
		vec.push_back(dat);
	}
	if(Judge(vec))
		cout << "Jolly" << endl;
	else
		cout << "Not jolly" << endl;

}

int main()
{
	vector<int> vec;
	Problem(vec);
	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