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

Magic of David Copperfield这道题的Special Judged 似乎不够全面,我的检验了还老wrong anwser,我的代码如下

Posted by 00348264 at 2004-11-19 21:48:23 on Problem 1710
#include<iostream.h>
void main()
{	
	long num;
	cin>>num;
	bool rec[200][200],nolast=true;
	long row=0,i,j,count,line=1;
	for(i=1;i<=num;i++)
	{ 
		rec[num][i]=true;
		rec[num-1][i]=true;
	}
	for(i=1,count=1;;i+=2,count++)
	{
		if(count%2&&nolast)	
			row++;
			cout<<i;
		if(row==num-1)
		{
			nolast=false;			
			if(!rec[num-1][line]&&!rec[num][line])
				line++;
			if((num-1+line-count)%2)
			{
				if(rec[num-1][line])
				{
					rec[num-1][line]=false;
					cout<<" "<<(num-2)*num+line;
				}
			}
			else
				if(rec[num][line])
				{
					rec[num][line]=false;
					cout<<" "<<(num-1)*num+line;
				}
			if(line==num&&(!rec[num-1][num]||!rec[num][num]))
				break;		
		}
		else
		for(j=1;j<=num;j++)
			if((j+row-count)%2)	
				cout<<" "<<(row-1)*num+j;
		cout<<endl;
	}
	cout<<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