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

我用穷举法,为什么检验的时候用每个Move挨个检验就对,用Clock来检验就不对呢?高手指点

Posted by 31311069 at 2004-11-14 00:34:56 on Problem 1166
int turnclock[10][10] = { {0},{1,2,4,5},{1,2,3},{2,3,5,6},{1,4,7},{2,4,5,6,8},{3,6,9},{4,5,7,8},{7,8,9},{5,6,8,9} };

int check ( ) // 能达目的就返回1,否则返回0
{
	int i , j ,tc[10] ; // tc暂时存clock状态
	for ( i = 1 ;i < 10 ; i ++ )
		tc[i] = clock[i] ;
	for ( i = 1; i < 10 ; i ++ )
		for ( j = 0 ; turnclock[i][j] ; j ++ )
			tc[turnclock[i][j]] += turn[i] ;
	for ( i = 1 ;i < 10 ; i ++ )
		if ( tc[i] % 4 )
			return 0 ;
		return 1 ;
}


int clockturn[10][6] = { {0},{1,2,4,0},{1,2,3,5,0},{2,3,6,0},{4,5,7,0},{1,3,5,7,9,0},{3,5,6,9,0},{4,7,8,0},{5,7,8,9,0},{6,8,9,0} };

int check ( ) // 返回值和上面程序一样
{
	int i , j , s ; // 用s暂时存每个clock状态
	for ( i = 1 ; i <= 9 ;i ++ )
	{
		s = clock[i] ;
		for ( j = 0 ; clockturn[i][j] ;j ++ )
			s += turn[clockturn[i][j]] ;
		if ( s % 4 )
			return 0 ;
	}
	return 1 ;
}


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