Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <numeric>
- #include <cmath>
- #include <queue>
- using namespace std;
- const int N = 500*501/4, mod = 1e9 + 7;
- long long n, dp[N+1], m;
- void read()
- {
- cin >> n;
- }
- void solve()
- {
- if (n * (n+1) % 4 != 0)
- {
- cout << 0; return ;
- }
- fill(dp + 1, dp + N + 1, 0);
- m = n * (n + 1)/4;
- dp[0] = 1;
- for (int i = 1; i <= n; ++ i)
- {
- for (int j = m; j >= i; -- j)
- {
- dp[j] = (dp[j] + dp[j - i]) % mod;
- }
- }
- cout << (dp[m] * (mod + 1)/2) % mod; // Nghich dao modulo
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- read();
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement