-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1352B.cpp
More file actions
55 lines (48 loc) · 1.13 KB
/
Copy path1352B.cpp
File metadata and controls
55 lines (48 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <bits/stdc++.h>
#define FOR(i, start, end) for(int i = start; i < end; i++)
using namespace std;
typedef long long LL;
void solve() {
int n, k;
cin >> n >> k;
vector<int> res;
if (k <= n) {
if ((n % k) == 0) {
FOR(i, 0, k)
res.push_back(n/k);
}
else if ((n & 1) && (k & 1)) {
while (k) {
res.push_back((k > 1) ? 1 : n);
n--; k--;
}
}
else {
if (k & 1 && (k << 1 <= n)) {
while (k) {
res.push_back((k > 1) ? 2 : n);
n -= 2; k--;
}
}
else if ((n - (k-1)) & 1) {
while (k) {
res.push_back((k > 1) ? 1 : n);
n--; k--;
}
}
}
}
if (!res.empty()) {
printf("YES\n");
int len = res.size();
FOR(i, 0, len) {
printf((i != len-1) ? "%d " : "%d\n", res[i]);
}
}
else printf("NO\n");
}
int main() {
int t;
cin >> t;
while (t--) solve();
}