p137.cpp
======================
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int n, k;

void read() { cin >> n >> k; }

void solve() {
    int a = k / n;
    int d = k % n;

    vector<int> ans(n, a);

    for(int t = 1; t < n; t++) {
        if(t * d % n == n - 1) {
            int x = 0;
            do {
                x = (x + t) % n;
                ans[x]++;
            } while(x != n - 1);
            break;
        }
    }

    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}

=================
statement.txt
======================
137. Funny Strings

time limit per test: 0.25 sec.
memory limit per test: 4096 KB


Let's consider a string of non-negative integers, containing N elements. Suppose these elements are S1 S2 .. SN, in the order in which they are placed inside the string. Such a string is called 'funny' if the string S1+1 S2 S3 .. SN-1 SN -1 can be obtained by rotating the first string (to the left or to the right) several times. For instance, the strings 2 2 2 3 and 1 2 1 2 2 are funny, but the string 1 2 1 2 is not. Your task is to find a funny string having N elements, for which the sum of its elements (S1+S2+..+SN) is equal to K.


Input

The input contains two integers: N (2<=N<=1000) and K (1<=K<=30000). Moreover, GCD(N,K)=1 (it can be proven that this is a necessary condition for a string to be funny).


Output

You should output one line containing the elements of the funny string found. These integers should be separated by blanks.

Hint

GCD(A,B) = the greatest common divisor of A and B.
The 'funny' strings are also named Euclid strings in several papers.


Sample Input

9 16
Sample Output

1 2 2 2 1 2 2 2 2
Author	: Mugurel Ionut Andreica
Resource	: SSU::Online Contester Fall Contest #2
Date	: Fall 2002

=================
