Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- ll mas[(ll)1e6] {};
- map<pair<ll,ll>,ll> countMap;
- int main()
- {
- ll N;
- cin >> N;
- for(ll n=1; n<=N; n++){
- 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)
- mas[n]+=(*it).second;
- }
- cout << endl << endl << N << " : " << mas[N] << endl << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement