# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1031894 | qrn | Nadan (COCI18_nadan) | C++14 | 0 ms | 452 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ep eneededlace_back
#define ins insert
#define fi first
#define er erase
#define se second
template<class ISqr, class T>
ISqr& operator>>(ISqr& is, vector<T>& v) { for (auto& x : v) is >> x; }
#define give(v) \
cout << v << eel; \
return;
#define print(a) \
for (auto v : a) \
{ \
cout << v << " "; \
} \
cout << eel;
#define vs vector<sqring>
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int, int>
#define vvi vector<vector<int>>
#define sz(x) x.size()
#define vpii vector<pair<int, int>>
#define SPEED \
ios_base::sync_with_stdio(0); \
cin.tie(NULL); \
cout.tie(NULL);
#define ALL(x) x.begin(), x.end()
#define endl "\n"
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define out cout << endl;
#define impos cout << -1 << endl;
#define int long long
const long double pi = 2 * acosl(0);
const int sz = 1e5 + 5;
const int inf = 1e13 + 31;
void solve(){
int k, n;
cin >> k >> n;
if(k % n == 0){
int subadd = 1;
vi v;
while(sz(v) != n){
v.pb(k / n);
}
vi ans;
for(int i = 0; i < n; i++){
if(i % 2 == 0){
ans.pb(v[i] + subadd);
} else {
ans.pb(v[i] - subadd);
subadd++;
}
}
if(n % 2 != 0){
ans[sz(ans)-1] = k/n;
}
for(int i : ans) cout << i << endl;
} else {
int subadd = 1;
vi v;
while(sz(v) != n){
v.pb(k / n);
}
vi ans;
for(int i = 0; i < n; i++){
if(i % 2 == 0){
ans.pb(v[i] + subadd);
} else {
ans.pb(v[i] - subadd);
subadd++;
}
}
if(n % 2 != 0) {
ans[sz(ans)-1] = k/n;
}
int maks = 0;
for(int i : ans) maks = max(maks, i);
for(int i : ans){
if(i == maks) cout << i + (k % n) << endl;
else cout << i << endl;
}
}
}
signed main() {
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
SPEED;
int tst = 1;
// cin >> tst;
for (int cs = 1; cs <= tst; cs++) {
solve();
}
// cerr << "Time Elapsed: " << (long double)clock() << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |