fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long int
  4. const int MAX = 1e5+7;
  5. const int MOD = 1e9+7;
  6. vector<vector<ll> > dp(MAX,vector<ll>(501,-1));
  7. ll S;
  8.  
  9. int solve(int i,ll sm){
  10.  
  11. if(dp[i][sm]!=-1) return dp[i][sm];
  12. if(i==0 && sm == S/2) return 1;
  13. else if(i==0) return 0;
  14.  
  15. ll mn = (solve(i-1,sm + i) + solve(i-1,sm)%MOD)%MOD;
  16. dp[i][sm] = mn;
  17. return mn;
  18. }
  19.  
  20.  
  21. int main(){
  22.  
  23. int n;
  24. cin>>n;
  25. S = (n*(n+1))/2;
  26. if(S%2) cout<<0<<'\n';
  27. else cout<<solve(n,0)/2<<'\n';
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0.11s 397656KB
stdin
7
stdout
4