Created
April 14, 2015 23:10
-
-
Save lan496/43cf64e10b3c03026f70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
long long dfs(int pos,int n,bool crd[][100],int y,int x){ | |
if(pos==n) return 1; | |
int dy[]={0,1,0,-1}; | |
int dx[]={1,0,-1,0}; | |
long long res=0; | |
for(int k=0;k<4;k++){ | |
int yk=y+dy[k]; | |
int xk=x+dx[k]; | |
if(crd[yk][xk]) continue; | |
crd[yk][xk]=true; | |
res+=dfs(pos+1,n,crd,yk,xk); | |
crd[yk][xk]=false; | |
} | |
return res; | |
} | |
int main(){ | |
int N=23; | |
for(int i=21;i<=N;i++){ | |
bool crd[100][100]; | |
crd[50][50]=true; | |
std::cout << i << ": "; | |
std::cout << dfs(0,i,crd,50,50) << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment