Codeforces Round #216 (Div. 2) B. Valera and Contest

OpenSoucre發表於2014-03-15
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int n,k,l,r,s_n,s_k;
    cin >> n >> k >> l >> r >> s_n >> s_k;
    int s_n_k = s_n-s_k;
    int average_k = s_k/k,left_k = s_k%k;
    vector<int> a(n,0);
    for(int i = 0 ; i < k ; ++ i ){
        a[i] = average_k;
        if(i < left_k) a[i]+=1;
    }
    if(s_n_k){   //注意n和k相等的情況
        int average_n_k = s_n_k / (n-k), left_n_k = s_n_k%(n-k);
        for(int  i = k ; i < n; ++ i){
            a[i] = average_n_k;
            if(i - k <  left_n_k) a[i] +=1;
        }
    }
    cout<<a[0];
    for(int i = 1; i < n ; ++ i) cout<<" "<<a[i];
    cout<<endl;
    return 0;
}

 

相關文章