Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
663 B
3
Indexable
Never
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long fibo[90];
    fibo[0] = 0;
    fibo[1] = 1;
    for (int i = 2; i < 90; ++i)
    {
        fibo[i] = fibo[i - 1] + fibo[i - 2];
    }
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        a[i] = i + 1;
    }
    int cnt = 1;
    while (next_permutation(a.begin(), a.end()))
    {
        if (binary_search(fibo, fibo + 90, cnt))
        {
            cout << cnt << ": ";
            for (int i = 0; i < n; ++i)
            {
                cout << a[i] << " ";
            }
            cout << endl;
        }
        ++cnt;
    }
    return 0;
}
Leave a Comment