求解!!!大神帮帮忙!!!

#include<cstdio>
int const A= -1;
int map[20][20]={{0}},n,m;
int main()
{
  scanf("%d %d",&n,&m);
  int x,y;
  scanf("%d %d",&x,&y);
  map[x][y]=A;
  if(x+2<n && y-1>0)//y
    map[x+2][y-1]=A;
  if(x+2<n && y+1<m)//y
    map[x+2][y+1]=A;
  if(x+1<n && y+2<m)//y
    map[x+1][y+2]=A;
  if(x-1>0 && y+2>m)//y
    map[x-1][y+2]=A;
  if(x-2>0 && y+1>m)//y
    map[x-2][y+1]=A;
  if(x-2>0 && y-1>0)//y
    map[x-2][y-1]=A;
  if(x-1>0 && y-2>0)//y
    map[x-1][y-2]=A;
  if(x+1<n && y-2>0)//y
    map[x+1][y-2]=A;
  for(int i=1;map[1][i]!= -1;i++)
    map[1][i]=1;
  for(int i=1;map[i][1]!= -1;i++)
    map[i][1]=1;
  for(x=1;x<=n;x++)
    for(y=1;y<=m;y++)
    {
      if(map[x-1][y]!= -1 && x-1>0)
        map[x][y]+=map[x-1][y];
      if(map[x][y-1]!= -1 && y-1>0)
        map[x][y]+=map[x][y-1];
    }
  printf("%d",map[n][m]);
  return 0;
}

请大神们帮我纠错!!!!!!!

1 条评论

  • @ 2016-07-29 15:19:31
    #include <bits/stdc++.h>
    int main() {
      long n,m,x,y;
      int l1[10] = {0,0,1,-1,1,-1,-2,-2,2,2};
      int l2[10] = {0,0,-2,-2,2,2,-1,1,1,-1};
      long long a[101][101];
      bool b[101][101];
      memset(a,0,sizeof(a));
      memset(b,false,sizeof(b));
      scanf("%ld %ld %ld %ld",&n,&m,&x,&y);
      for (int i = 1;i <= 9;i++)
        if (y+l2[i] >= 0 && x+l1[i] >= 0)
          b[x+l1[i]][y+l2[i]] = true;
      a[0][0] = 1;
      for (int i = 1;i <= m;i++)
        if (!b[0][i]) a[0][i] = a[0][i-1];
      for(int i = 1;i <= n;i++)
        if(!b[i][0]) a[i][0] = a[i-1][0];
      for(int i = 1;i <= n;i++)
        for(int j = 1;j <= m;j++)
          if (!b[i][j]) a[i][j] = a[i-1][j]+a[i][j-1];
      printf("%I64d",a[n][m]);
      return 0;
    }
    
  • 1

信息

ID
1121
难度
4
分类
动态规划 点击显示
标签
递交数
9583
已通过
3786
通过率
40%
被复制
25
上传者