Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <cassert>
- #include <ctime>
- #include <cmath>
- #include <algorithm>
- #include <string>
- #include <vector>
- #include <deque>
- #include <queue>
- #include <list>
- #include <set>
- #include <map>
- //#include <iostream>
- #define pb push_back
- #define mp make_pair
- #define TASKNAME "ideal"
- #ifdef LOCAL
- #define eprintf(...) fprintf(stderr,__VA_ARGS__)
- #else
- #define eprintf(...)
- #endif
- #define TIMESTAMP(x) eprintf("[" #x "] Time = %.3lfs\n",clock()*1.0/CLOCKS_PER_SEC)
- #ifdef linux
- #define LLD "%lld"
- #else
- #define LLD "%I64d"
- #endif
- #define sz(x) ((int)(x).size())
- using namespace std;
- typedef long double ld;
- typedef long long ll;
- typedef vector<ll> vll;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- typedef vector<bool> vb;
- typedef vector<vb> vvb;
- typedef pair<int, int> pii;
- typedef pair <ll, ll> pll;
- typedef vector<pii> vpii;
- const int inf = 1e9;
- const double eps = 1e-9;
- const int INF = inf;
- const double EPS = eps;
- #ifdef LOCAL
- struct __timestamper {
- ~__timestamper(){
- TIMESTAMP(end);
- }
- } __Timestamper;
- #else
- struct __timestamper {};
- #endif
- /*Template end*/
- vector< vector<int> > ans;
- vector<int> cur;
- int n;
- void go(int sum){
- if (!ans.empty() && ans[0].size() < cur.size()) return;
- if (sum == n){
- if (!ans.empty() && ans[0].size() > cur.size()) ans.clear();
- ans.pb(cur);
- return;
- }
- if (sum + 2 * sum + 1 <= n) {
- cur.pb(2*sum + 1);
- go(sum + 2*sum + 1);
- cur.pop_back();
- }
- if (sum + cur.back() <= n){
- cur.pb(cur.back());
- go(sum + cur.back());
- cur.pop_back();
- }
- }
- int main()
- {
- #ifdef LOCAL
- freopen(TASKNAME".in","r",stdin);
- freopen(TASKNAME".out","w",stdout);
- #endif
- scanf("%d\n", &n);
- cur.pb(1);
- go(1);
- assert(!ans.empty());
- sort(ans.begin(), ans.end());
- printf("%d %d\n", ans.size(), ans[0].size());
- for (int i = 0; i < (int)ans.size(); i++){
- for (auto x : ans[i])
- printf("%d ", x);
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement