Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
44069 WZH 求和比较 C++ Accepted 1 MS 264 KB 443 2024-03-26 21:29:32

Tests(1/1):


#include<bits/stdc++.h> using namespace std; int main() { int n,m; int sum; int v; int dp[35][630]; cin>>n>>m; sum=(1+n)*n/2; v=(sum-m)/2; for(int i=0;i<=n;i++) dp[i][0]=1; if(m>sum||(sum-m)%2!=0) { cout<<0; return 0; } for(int i=1;i<=n;i++) { for(int j=1;j<=v;j++) { if(j>=i) dp[i][j]=dp[i-1][j-i]+dp[i-1][j]; if(j<i) dp[i][j]=dp[i-1][j]; } } cout<<dp[n][v]; return 0; }


Judgement Protocol: