Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <ext/rope>
- #define clr(x) memset((x), 0, sizeof(x))
- #define all(x) (x).begin(), (x).end()
- #define pb push_back
- #define mp make_pair
- #define For(i, st, en) for(int i=(st); i<=(int)(en); i++)
- #define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)
- #define forn(i, n) for(int i=0; i<(int)(n); i++)
- #define ford(i, n) for(int i=(n)-1; i>=0; i--)
- #define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
- #define in(x) int (x); input((x));
- #define x first
- #define y second
- #define less(a,b) ((a) < (b) - EPS)
- #define more(a,b) ((a) > (b) + EPS)
- #define eq(a,b) (fabs((a) - (b)) < EPS)
- #define remax(a, b) ((a) = (b) > (a) ? (b) : (a))
- #define remin(a, b) ((a) = (b) < (a) ? (b) : (a))
- using namespace std;
- template <typename T>
- T gcd(T a, T b)
- {
- while (b > 0)
- {
- a %= b;
- swap(a, b);
- }
- return a;
- }
- typedef long double ld; template <class _T> inline _T sqr(const _T& x) {return x * x;} template <class _T> inline string tostr(const _T& a) {ostringstream os(""); os << a; return os.str();} const ld PI = 3.1415926535897932384626433832795L; const double EPS = 1e-9; char TEMPORARY_CHAR; typedef long long ll; typedef unsigned long long ull; typedef set < int > SI; typedef vector < int > VI; typedef vector < vector < int > > VVI; typedef map < string, int > MSI; typedef pair < int, int > PII; const int INF = 1e9; inline void input(int &a) {a = 0; while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') && (TEMPORARY_CHAR != '-')){} char neg = 0; if (TEMPORARY_CHAR == '-') {neg = 1; TEMPORARY_CHAR = getchar();} while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0') {a = 10 * a + TEMPORARY_CHAR - '0'; TEMPORARY_CHAR = getchar();} if (neg) a = -a;} inline void out(int a) {if (!a) putchar('0'); if (a < 0) {putchar('-'); a = -a;} char s[10]; int i; for(i = 0; a; ++i) {s[i] = '0' + a % 10; a /= 10;} ford(j, i) putchar(s[j]);} inline int nxt() {in(ret); return ret;}
- vector <int> a;
- vector <vector <int> > ans;
- int n;
- void rec3(int s) {
- if (s == n) {
- if (a.size() < best)
- ans.clear();
- if (a.size() <= best) {
- ans.push_back(a);
- best = min(best, (int)a.size());
- }
- return;
- }
- if (3 * s + 1 <= n) {
- a.push_back(2 * s + 1);
- rec3(3 * s + 1);
- a.pop_back();
- }
- if (s + a.back() <= n) {
- a.push_back(a.back());
- rec3(s + a.back());
- a.pop_back();
- }
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- a.push_back(1);
- cin >> n;
- rec3(1);
- cout << ans.size() << " " << ans[0].size() << endl;
- sort(all(ans));
- for (int i = 0; i < ans.size(); ++i) {
- for (int v : ans[i]) {
- cout << v << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment