-
Notifications
You must be signed in to change notification settings - Fork 2
/
1352B.cpp
111 lines (101 loc) · 2.97 KB
/
1352B.cpp
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Author : Mars_Coder
// https://codeforces.com/problemset/problem/1352/B
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
#define ln "\n" // no flush, oppos of endl
#define _flush endl
#define stop_sync ios::sync_with_stdio(false) // not to use c-style io
#define untie_ios cin.tie(nullptr) // no flush
#define lli long long int
#define vi vector<int>
#define vii vector<lli>
#define vch vector<char>
#define double long double
#define vss vector<string>
#define vpp(T1, T2) vector<pair<T1, T2>>
#define pq priority_queue // high prec.
#define pqq(T) priority_queue<T, vector<T>, greater<T>>
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define Fi(p) get<0>(p)
#define Sc(p) get<1>(p)
#define sz(x) int ((x).size())
#define all(x) (x).begin(), (x).end()
#define bin_sc(a, x) binary_search(all(a), x)
#define lbd(a, x) lower_bound(all(a), x) // an iter.
#define ubd(a, x) upper_bound(all(a), x) // an iter.
#define eq_seg(a, x) equal_range(all(a), x) // a pair of lb, ub
#define FIXED(x) cout << fixed << setprecision(x)
#define _print(x) cout << (#x) << ": " << (x) << ln
#define uceil(a, b) ((a + b - 1) / (b))
const string yms[]{"YES", "Yes", "yes"};
const string nms[]{"NO", "No", "no"};
const double PI = acos(-1.0L);
struct{const int i = (1e9) + 7; const lli l = (lli)(1e9) + 7ll;}MOD;
struct{const int i = INT_MAX; const lli l = LLONG_MAX;}inf;
lli uround(lli a, lli b) {return (((a) * 1.0000) / (b) + 0.500000);}
lli pow2(lli p){return (1ll << p);}
// nxt templ.
int main(void){
stop_sync;
untie_ios;
#ifndef ONLINE_JUDGE
//freopen("generator.txt", "r", stdin);
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
int t(1);
cin >> t;
while(t--){
lli n, k;
cin >> n >> k;
vii ans;
if((n - (k - 1)) % 2){
for(lli i = 1; i < k; ++i) ans.pb(1);
ans.pb(n - (k - 1));
}else if((n - (k - 1) * 2) % 2 == 0){
for(lli i = 1; i < k; ++i) ans.pb(2);
ans.pb(n - (k - 1) * 2);
}else{
cout << nms[0] << ln;
continue;
}
bool flag = 0;
if(ans[0] % 2){
for(lli i = 0; i < k; ++i){
if(ans[i] <= 0){
flag = 1;
break;
}
}
}else{
for(lli i = 0; i < k; ++i){
if(ans[i] <= 0){
flag = 1;
break;
}
}
}
if(flag) cout << nms[0] << ln;
else{
cout << yms[0] << ln;
for(auto i: ans) cout << i << ' '; cout << ln;
}
}
return 0;
}
/*
some familiar issues & sugg.:
!----> [RE-READ THE CODE!]
!----> [invariants to array?]
!----> [look at global variables and their values]
!----> [llabs() for long long int type]
!----> [look at input size and time limit]
!----> [No sync with puts fn]
!----> [prefix vs suffix]
!----> [array contains duplicate values!]
!----> [(a/b+1)*b vs uceil(a,b)*b]
*/