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

求助:为什么老是runtime error呀

Posted by 00448322 at 2005-04-05 13:15:43 on Problem 2081
#include <iostream.h>

bool show[50001];

void main()
{
	int n;
	int b;
	while(1)
	{
		cin>>n;
		if(n==-1)
			break;
		if(n==0)
		{	cout<<"0\n";
			continue;
		}
		if(n==1)
		{	cout<<"1\n";
			continue;
		}
		if(n==2)
		{	cout<<"3\n";
			continue;
		}
		for(int j=0;j<50001;j++)
			show[j]=false;
		show[0]=true;
		show[1]=true;
		show[3]=true;
		b=3;
		for(int i=3;i<=n;i++)
		{	
			if(show[b-i]==false&&b-i>0)
			{
				b=b-i;
				show[b]=true;
			}
			else
			{	
				b=b+i;
				show[b]=true;
			}
				
		}
		cout<<b<<endl;
	}
	

}

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