为什么0分?

P1644 跳马问题

因为你是傻逼!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
by 影皇 @ 2017-07-12 20:25:09


```cpp #include<iostream> #include<cstdio> #include<cmath> using namespace std; int step[5][2]={{0,0},{1,2},{2,1},{-1,2},{-2,1}}; int n, m,ans=0; void dfs(int x,int y){ if(x==m&&y==n){ ans++; return; } for(int i=1;i<=4;i++){ if(x+step[i][0]>=0&&x+step[i][0]<=m&&y+step[i][1]>=0&&y+step[i][1]<=n){ dfs(x+step[i][0],y+step[i][1]); } } } int main(){ //freopen("horse.in", "r", stdin); //freopen("horse.out", "w", stdout); cin>>m>>n; dfs(0,0); cout<<ans; return 0; } ``` 已改正 注意判定到达终点的代码放在for循环外面
by 随心唯爱 @ 2017-08-20 20:20:05


|