提交时间:2023-01-08 15:41:18
运行 ID: 3485
#include<bits/stdc++.h> using namespace std; int dp[40][650]; int main(){ int n,m; cin>>n>>m; int sum=(1+n)*n/2; if(m>sum||(sum-m)%2==1){ cout<<0;return 0; } int v=(sum-m)/2; for(int i=0;i<=n;i++)dp[i][0]=1; for(int i=1;i<=n;i++){ for(int j=1;j<=v;j++){ if(i<=j)dp[i][j]=dp[i-1][j-i]+dp[i-1][j]; else dp[i][j]=dp[i-1][j]; } } cout<<dp[n][v]; return 0; } /* #include<cstdio> freopen("文件名.in","r",stdin); freopen("文件名.out","w",stdout); */