zoukankan      html  css  js  c++  java
  • code vs 1216 跳马问题

     时间限制: 1 s
     空间限制: 128000 KB
     题目等级 : 黄金 Gold
     
     
     
    题目描述 Description

    题目

    输入描述 Input Description

    第一行两个正整数M,N(0<M,N≤300)分别表示行和列
    第二行两个正整数,表示起点的行列坐标。
    第三行两个正整数,表示终点的行列坐标

    输出描述 Output Description

    一个正整数,表示方案总数对123456求余

    样例输入 Sample Input

    3 3

    1 1

    2 3

    样例输出 Sample Output

    1

    数据范围及提示 Data Size & Hint

    1

    分类标签 Tags 

    思路:记忆化搜索,爆搜gg。

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #define mod 123456
    using namespace std;
    int f[350][350];
    int n,m,sx,sy,tx,ty,ans;
    int dfs(int x,int y){
        if(x<1||x>n||y<1||y>m)    return 0;
        if(f[x][y])    return f[x][y];
        return f[x][y]+=(dfs(x-1,y-2)+dfs(x-1,y+2)+dfs(x-2,y-1)+dfs(x-2,y+1));
    }
    int main(){
        scanf("%d%d%d%d%d%d",&n,&m,&sx,&sy,&tx,&ty);
        f[sx][sy]=1;
        dfs(tx,ty);
        cout<<f[tx][ty]%mod;
    }
    细雨斜风作晓寒。淡烟疏柳媚晴滩。入淮清洛渐漫漫。 雪沫乳花浮午盏,蓼茸蒿笋试春盘。人间有味是清欢。
  • 相关阅读:
    react的路由以及传值方法
    三连击
    给网页添加鼠标样式
    单词统计(续)
    个人课程总结
    构建之法阅读笔记02
    构建之法阅读笔记01
    第十六周总结
    计算最长英语单词链
    第十五周总结
  • 原文地址:https://www.cnblogs.com/cangT-Tlan/p/8213586.html
Copyright © 2011-2022 走看看