Gym - 101810B ACM International Collegiate Programming Contest (2018)

bryce1010模板
http://codeforces.com/gym/101810

#include <bits/stdc++.h>

using namespace std;
#define ll long long
int main() {
    int T;
    cin >> T;
    while (T--)
    {
        ll n, x;
        cin >> x >> n;
        if (n == 1) {
            cout << x << endl;
            continue;
        }
        ll time = x / (2 * n - 2);
        ll ad = x % (2 * n - 2);
        vector<ll>ans(n);
        for (int i(0); i < n; i++) {
            if (i != 0 && i != n - 1)ans[i] += time * 2;
            else ans[i] += time;
        }
        for (int i(0); i < n&&ad > 0; i++, ad--) {
            ans[i]++;
        }
        for (int i(n - 2); ad > 0; ad--, i--) {
            ans[i]++;
        }
        for (int i(0); i < n; i++) {
            if (i == 0)cout << ans[i];
            else cout << " " << ans[i];
        }
        cout << endl;
    }
    return 0;
}

posted @ 2018-07-29 15:40  Bryce1010  阅读(132)  评论(0编辑  收藏  举报