int f(int N,int s ,int rest,int cur)
{
if(rest==0)
{
return cur==s?1:0;
}
if(cur==1)
{
return f(N,s,rest-1,2);
}
if(cur==N)
{
return f(N,s,rest-1,N-1);
}
return f(N,s,rest-1,cur-1)+f(N,s,rest-1,cur+1);
}
“Devil组”引证GPT后的撰写: