Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define eps 1e-9;
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- ll res1, res2;
- ll mas[(ll)1e6];
- map<pair<ll,ll>,ll> countMap;
- int main()
- {
- cin.sync_with_stdio(false);
- cout.sync_with_stdio(false);
- ll N;
- cin >> N;
- countMap[{1,1}]=1;
- mas[1]=1;
- for(ll n=2; n<=N; n++){
- res2=0;
- for (ll rest=n; rest>0; rest--)
- if (rest<n-rest)
- countMap[{n, n-rest}]=mas[rest];
- else
- for(map<pair<ll,ll>,ll>::iterator it = countMap.lower_bound({rest, 1}); it!=countMap.upper_bound({rest, n-rest-1}); ++it)
- countMap[{n, n-rest}]+=(*it).second;
- countMap[{n,n}]=1;
- for (map<pair<ll,ll>,ll>::iterator it = countMap.lower_bound({n, 0}); it!=countMap.upper_bound({n,n}); ++it)
- res2+=(*it).second;
- mas[n]=res2;
- }
- cout << endl << endl << N << " : " << res2 << endl << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement