csdoge


私信TA

用户名:csdoge

访问量:2494

签 名:

等  级
排  名 2011
经  验 2408
参赛次数 0
文章发表 23
年  龄 0
在职情况 学生
学  校 南京邮电大学
专  业

  自我简介:

TA的其他文章

【c++】线性筛素数
浏览:118
打印十字图
浏览:68
走方格,dfs
浏览:177

解题思路:

注意事项:

参考代码:

#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<vector>

#include<utility>

#include<map>

using namespace std;

bool vis[35][35];

int n,m,res=0;

int road[2][2]={{0,1},{1,0}};

bool in(int tx,int ty){

return tx>=1&&tx<=n&&ty>=1&&ty<=m;

}

void dfs(int x,int y){

if(x==n&&y==m){

res++;

return;

}

vis[x][y]=true;

for(int i=0;i<=1;i++){

int tx=x+road[i][0];

int ty=y+road[i][1];

if(in(tx,ty)&&!vis[tx][ty]&&!(tx%2==0&&ty%2==0)){

dfs(tx,ty);

}

vis[x][y]=false;

}

int main(){

cin>>n>>m;

    dfs(1,1);

    cout<<res<<endl;

return 0;

}


 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区