HDU 1564 Play a game

 

这题我刚开始推出了n=1,2,3的情况,自己在大胆的猜测是奇偶性,发现A了;

后来打表也是奇偶性质;

打表代码:

View Code
 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 int n ;
 4 int graph[1010][1010] ;
 5 int tab[4][2] = {-1,0,1,0,0,-1,0,1} ; 
 6 int dfs (int x, int y)
 7 {    
 8      int xx, yy, i, ans ;          
 9      for (i = 0 ; i < 4 ; i++)    
10      {        
11            xx = x + tab[i][0] ;       
12            yy = y + tab[i][1] ;        
13            if (xx < 0 || xx >= n) continue ;        
14            if (yy < 0 || yy >= n) continue ;        
15            if (graph[xx][yy]) continue ;        
16            graph[xx][yy] = 1 ;        
17            ans = dfs (xx, yy) ;        
18            graph[xx][yy] = 0 ;        
19            if (ans == 0) return 1 ; //如果下一点是必败点  那么该点一定是必胜点;   
20      }    
21      return 0 ;
22 }
23 int main ()
24 {    
25      graph[0][0] = 1 ;    
26      for (n = 1 ; n <= 8 ; n++)        
27      printf ("%d, %d\n", n, dfs (0,0)) ;
28      system( "pause" ); 
29      return 0;
30 }
View Code
 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<algorithm>
 5 #include<cmath>
 6 #include<queue>
 7 #include<set>
 8 #include<map>
 9 #include<vector>
10 using namespace std;
11 
12 int main(  )
13 {
14      int n;
15      while( scanf( "%d" ,&n ),n )
16      {       
17         if( !(n %= 2) ) puts( "8600" );
18         else puts( "ailyanlu" );
19       }
20     //system( "pause" );
21     return 0;
22 }

 

posted @ 2012-04-19 20:40  wutaoKeen  阅读(208)  评论(0编辑  收藏  举报