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:大家帮我看看,为什么总是WA?帮我改改

Posted by chenmingqiang at 2006-04-25 20:32:05 on Problem 2575
In Reply To:大家帮我看看,为什么总是WA?帮我改改 Posted by:579 at 2006-03-19 19:15:54
> #include<iostream>
> using namespace std;
> int main()
> {
> 	int n, m, i, j, t;
> 	int c = 0;
> 	int *a, *b;
> 	while(1)
> 	{
> 	cin >> n;
> 	b = new int[n];
> 	for(i=0; i<n; i++)
> 	{
> 		cin >> m;
> 		if(m<0)
> 			m = -m;
> 		b[i] = m;
> 	}
> 	if(n==1)
> 	{
> 		cout << "Not jolly" << endl;
> 		return 0;
> 	}
> 	t = n - 1;
> 	a = new int[t];
> 	for(i=1; i<=t; i++)
> 		a[i] = i;
> 	for(i=0; i<n; i++)
> 	{
> 		if(b[i]==0||b[i]>=n)
> 			c++;
> 		else
> 		{
> 			for(j=1; j<=t; j++)
> 			{
> 				if(b[i]==a[j])
> 				{
> 					a[j] = 0;
> 					break;
> 				}
> 			}
> 			if(j>t)
> 				c++;
> 		}
> 		if(c>1)
> 		{
> 			cout << "Not jolly" << endl;
> 			break;
> 		}
> 	}
> 	if(i==n)
> 		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