zoukankan      html  css  js  c++  java
  • 【NOIP2002】【codevs1010】过河卒

    problem

    solution

    codes

    //填表法
    #include<iostream>
    using namespace std;
    int n, m, x, y, a[20][20], f[20][20];
    int main(){
        cin>>n>>m>>x>>y; x++;y++;n++;m++;//+1方便赋初始值
        //9 points could'n be find
        a[x][y] = 1;
        a[x-1][y-2] = a[x-1][y+2] = a[x+1][y-2] = a[x+1][y+2] = 1;
        a[x-2][y-1] = a[x-2][y+1] = a[x+2][y-1] = a[x+2][y+1] = 1;
        f[0][1] = 1; //边界
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)
                if(!a[i][j])f[i][j] = f[i-1][j]+f[i][j-1];
        cout<<f[n][m]<<"
    ";
        return 0;
    }
    //刷表法
    #include<iostream>
    using namespace std;
    int n, m, x, y, a[20][20], f[20][20];
    int main(){
        cin>>n>>m>>x>>y;
        a[x][y] = 1;
        a[x-1][y-2] = a[x-1][y+2] = a[x+1][y-2] = a[x+1][y+2] = 1;
        a[x-2][y-1] = a[x-2][y+1] = a[x+2][y-1] = a[x+2][y+1] = 1;
        f[0][0] = 1;//初始值, 刷表时不会覆盖所以可以直接放
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= m; j++){
                if(!a[i+1][j])f[i+1][j] += f[i][j];
                if(!a[i][j+1])f[i][j+1] += f[i][j];
            }
        }
        cout<<f[n][m]<<"
    ";
        return 0;
    }
  • 相关阅读:
    百度网盘免费下载加速
    linux docker 知识点总结
    openwrt 支持 EC200T
    openwrt 如何添加新设备支持
    openwrt DEPEND
    menuconfig kconfig
    golang 汇编
    按值传递
    YAPI认证用户利用Mock功能远程代码执行事件通告
    携程持久化KV存储实践
  • 原文地址:https://www.cnblogs.com/gwj1314/p/9444773.html
Copyright © 2011-2022 走看看