博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++马拦过河卒
阅读量:2147 次
发布时间:2019-04-30

本文共 592 字,大约阅读时间需要 1 分钟。

这道题可以用递推,简单

#include 
using namespace std;int ma[8][2]={
{
1,-2},{
2,-1},{
2,1},{
1,2},{
-1,-2},{
-2,-1},{
-2,1},{
-1,2}};long long int n,m,sum=0,a[1000][1000],k,l;int main(){
cin>>n>>m>>k>>l; int q,w; for(int i=0;i<=n;i++) a[i][0]=1; for(int i=0;i<=m;i++) a[0][i]=1; for(int i=0;i<8;i++){
q=k+ma[i][0]; w=l+ma[i][1]; if(q>=0&&q<=n&&w>=0&&w<=m) a[q][w]=-1; } a[k][l]=-1; int p=0; while(p<=m){
if(a[0][p]==-1) a[0][p+1]=-1; p++; } p=0; while(p<=n){
if(a[p][0]==-1) a[p+1][0]=-1; p++; } for(int i=1;i<=n+m;i++){
for(int j=1;j

转载地址:http://quggf.baihongyu.com/

你可能感兴趣的文章
内存堆与栈
查看>>
Leetcode C++《每日一题》20200621 124.二叉树的最大路径和
查看>>
Leetcode C++《每日一题》20200622 面试题 16.18. 模式匹配
查看>>
Leetcode C++《每日一题》20200625 139. 单词拆分
查看>>
Leetcode C++《每日一题》20200626 338. 比特位计数
查看>>
Leetcode C++ 《拓扑排序-1》20200626 207.课程表
查看>>
Go语言学习Part1:包、变量和函数
查看>>
Go语言学习Part2:流程控制语句:for、if、else、switch 和 defer
查看>>
Go语言学习Part3:struct、slice和映射
查看>>
Go语言学习Part4-1:方法和接口
查看>>
Leetcode Go 《精选TOP面试题》20200628 69.x的平方根
查看>>
Leetcode C++ 剑指 Offer 09. 用两个栈实现队列
查看>>
Leetcode C++《每日一题》20200707 112. 路径总和
查看>>
云原生 第十一章 应用健康
查看>>
Leetcode C++ 《第202场周赛》
查看>>
云原生 第十二章 可观测性:监控与日志
查看>>
Leetcode C++ 《第203场周赛》
查看>>
云原生 第十三章 Kubernetes网络概念及策略控制
查看>>
《redis设计与实现》 第一部分:数据结构与对象 || 读书笔记
查看>>
《redis设计与实现》 第二部分(第9-11章):单机数据库的实现
查看>>