Walker_Syw @ 2021-10-11 19:34:59
输入8 6 0 4,答案应该是1617,我却显示1638
import java.util.Scanner;
public class Main
{
public static void main(String []args)
{
Scanner scan=new Scanner(System.in);
int []x=new int[4];
for(int i=0;i<4;i++)
{
x[i]=Integer.parseInt(scan.next());
}
boolean [][]y=new boolean[x[0]+1][x[1]+1];
int [][]z=new int[x[0]+1][x[1]+1];
for(int i=0;i<=x[0];i++)
{
for(int j=0;j<=x[1];j++)
{
y[i][j]=true;
if((i==0||j==0)&&(i!=j))
z[i][j]=1;
else
z[i][j]=0;
}
}
y[x[2]][x[3]]=false;
y[x[2]+1][x[3]+2]=false;
y[x[2]+2][x[3]+1]=false;
if(x[2]>=1&&x[2]<2)
{
if(x[3]>=1&&x[3]<2)
{
y[x[2]-1][x[3]+2]=false;
y[x[2]+2][x[3]-1]=false;
}
else if(x[3]<1)
{
y[x[2]-1][x[3]+2]=false;
}
else if(x[3]>=2)
{
y[x[2]-1][x[3]+2]=false;
y[x[2]-1][x[3]-2]=false;
y[x[2]+1][x[3]-2]=false;
y[x[2]+2][x[3]-1]=false;
}
}
else if(x[2]<1)
{
if(x[3]>=1&&x[3]<2)
{
y[x[2]+2][x[3]-1]=false;
}
else if(x[3]>=2)
{
y[x[2]+1][x[3]-2]=false;
y[x[2]+2][x[3]-1]=false;
}
}
else if(x[2]>=2)
{
if(x[3]>=1&&x[3]<2)
{
y[x[2]-2][x[3]-1]=false;
y[x[2]-2][x[3]+1]=false;
y[x[2]-1][x[3]+2]=false;
y[x[2]+2][x[3]-1]=false;
}
else if(x[3]<1)
{
y[x[2]-2][x[3]+1]=false;
y[x[2]-1][x[3]+2]=false;
}
else if(x[3]>=2)
{
y[x[2]-2][x[3]-1]=false;
y[x[2]-1][x[3]-2]=false;
y[x[2]-2][x[3]+1]=false;
y[x[2]-1][x[3]+2]=false;
y[x[2]+1][x[3]-2]=false;
y[x[2]+2][x[3]-1]=false;
}
}
for(int i=1;i<=x[0];i++)
{
for(int j=1;j<=x[1];j++)
{
if(!y[i][j])
{
z[i][j]=0;
}
else
{
z[i][j]=z[i-1][j]+z[i][j-1];
}
}
}
System.out.print(z[x[0]][x[1]]);
}
}
by mcyqwq @ 2021-10-11 19:38:18
?
验证码jjgg
by MatrixGroup @ 2021-10-11 19:41:36
输入8 6 0 4,答案应该是1617,我却显示1638
发错题了吧(
by matianchen @ 2021-11-07 13:11:42
?\ 发错题了吧