用搜索(bfs,dfs)做了半天,都超时,原来是dp;
参考博客:http://www.cnblogs.com/liuzezhuang/archive/2012/07/29/2613820.html
#include <iostream>
#include<cstring>
#include<queue>
#include<cstdlib>
#include<cstdio>
using namespace std; int map[][],b[][];
int main()
{
int h,w,i,j;
cin>>h>>w; for(i=; i<=h; i++)
for(j=; j<=w; j++)
cin>>map[i][j];
b[h][]=; for(i=h; i>=; i--)
for(j=; j<=w; j++)
{
if(map[i][j])
b[i][j]=;
else if(i==h&&j>)
b[i][j]=b[i][j-];
else if(j==&&i<h)
b[i][j]=b[i+][j];
else if(i!=h&&j!=&&map[i][j]!=)
b[i][j]=b[i+][j]+b[i][j-];
}
cout<<b[][w]<<endl;
return ;
}