Problem:
Score : 800 points

Problem Statement

In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.

Let the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicographically smallest one.

Constraints

1 \leq N,K \leq 3 × 10^5

N and K are integers.

Input

Input is given from Standard Input in the following format:

K N

Output

Print the (X/2)-th (rounded up to the nearest integer) lexicographically smallest sequence listed in FEIS, with spaces in between, where X is the total number of sequences listed in FEIS.

Sample Input 1

3 2

Sample Output 1

2 1

There are 12 sequences listed in FEIS: (1),(1,1),(1,2),(1,3),(2),(2,1),(2,2),(2,3),(3),(3,1),(3,2),(3,3).
The (12/2 = 6)-th lexicographically smallest one among them is (2,1).

Sample Input 2

2 4

Sample Output 2

1 2 2 2

Sample Input 3

5 14

Sample Output 3

3 3 3 3 3 3 3 3 3 3 3 3 2 2

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>

using namespace std;

#undef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool x) { return (x ? "T" : "F"); }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename V>
string to_string(V v) {
    bool f = true; string res = "[";
    for (const auto& x: v) {
        if (!f) res += ", ";
        f = false;
        res += to_string(x); } res += "]";
    return res;
}
void debug() { cerr << endl; }
template <typename H, typename... T>
void debug(H h, T... t) { cerr << " " << to_string(h); debug(t...); }
#ifdef LOCAL
#define dbg(args...) cerr<<"("<<#args<<") =", debug(args)
#else
#define dbg(args...) 2019
#endif
using ll=long long ;

void solve() {
    int k,n;
    cin >> k >> n;
    if (k%2==0) {
        cout << (k/2) << ' ';
        for (int _ = 1; _ < n; _++) {
            cout << k << ' ';
        }
        return;
    }
    const ll LIM = 1e6;
    vector<ll> len = {1, k};
    while (len.back()<LIM) {
        ll x = (1+len.back())*k;
        len.emplace_back(x);
    }
    int m = len.size() - 1;
    vector<int> res;
    for (int i = n; i > m; i--) {
        res.emplace_back((k+1)/2);
    }
    int shift = max(0, n-m);
    m = min(n,m);
    ll nth = (len[m]-shift+1)/2;
    assert(nth>0);
    dbg(m, nth);
    dbg(len);
    function<void(int,ll)> calc = [&](int d, ll i){
        assert(i < len[d]);
        res.emplace_back(1 + i/(len[d]/k));
        i %= (len[d]/k);
        assert(i <= len[d-1]);
        if (i == 0) return;
        calc(d-1, i-1);
    };
    calc(m, nth-1);
    for (auto& x: res) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}