#include
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define _zero(a) memset(a, 0, sizeof(a))
#define endl 'n'
#define int long long
#define mp make_pair
#define PII pair
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define PII pair
typedef long long ll;
typedef double dd;
typedef long double ld;
using namespace std;
const int inf = 1e10;
const int M = 998244353;
const ld pi = atan2(0, -1);//arctan(y/x);
const ld eps = 1e-8;
const int N = 110;
int n;
int path[N];
bool dfs(int u, int deep)
{
if (u == deep) return path[u - 1] == n;
bool st[N] = {false};
for (int i = u - 1; i >= 0; i --)
for (int j = i; j >= 0; j --) {
int k = path[i] + path[j];
if (k <= n && k >= path[u - 1] && !st[k]) {
st[k] = true;
path[u] = k;
if (dfs(u + 1, deep)) return true;
}
}
return false;
}
signed main()
{
IOS;
while (cin >> n && n) {
int deep = 1;
path[0] = 1;
while (!dfs(1, deep)) deep ++;
for (int i = 0; i < deep; i++) cout << path[i] << " ";
cout << endl;
}
return 0;
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)