fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long int
  3. #define N 101
  4. #define mod 1000000007
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. ll n;
  10. cin >> n;
  11. ll sum = (n*(n + 1)) / 2;
  12. if(sum &1)
  13. {
  14. cout << "0";
  15. return 0;
  16. }
  17. else
  18. {
  19. sum /= 2;
  20. ll dp[2][sum+1];
  21. for(ll i = 0 ; i < 2;i++)
  22. dp[i][0] = 1;
  23. for(ll i = 1;i <= sum;i++)
  24. dp[0][i] = 0;
  25.  
  26. for(ll i = 1; i <= n;i++)
  27. {
  28. for(ll j = 1; j <= sum;j++)
  29. {
  30. if(i <= j)
  31. dp[1][j] = (dp[0][j] + dp[0][j - i]) % mod;
  32. else
  33. dp[1][j] = dp[0][j];
  34. }
  35. for(ll j = 0;j <= sum;j++)
  36. dp[0][j] = dp[1][j];
  37. }
  38. cout << dp[1 ][sum]/2;
  39. }
  40. return 0;
  41. }
  42.  
Runtime error #stdin #stdout 0s 4280KB
stdin
Standard input is empty
stdout
Standard output is empty