1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//Author: Piotr Zielinski
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
const int N = 100;
int gSize = 0;

vector<int> dp(N);
vector<vector<int>> g(N);

void gen(int n) {
    dp[1] = 1;
    dp[2] = 1;
    g[2].push_back(1);
    int nd = 0, i = 2;
    while(dp[i] < n) {
        ++i, ++nd;
        while(dp[i-1] + dp[nd] > n) --nd;
        dp[i] = dp[i-1] + dp[nd];
        g[i].push_back(i-1);
        g[i].push_back(nd);
    }
    gSize = i + 1;
}

void printG() {
    cout << gSize - 1 << "\n";
    int n = gSize;
    while(gSize --> 1) {
        for(auto I : g[gSize])
            cout << n - I << " ";
        for(int i = 2 - g[gSize].size();i > 0;--i)
            cout << -1 << " ";
        cout << "\n";
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;

    gen(n);
    printG();

    return 0;
}