-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB_Taisia_and_Dice.cpp
72 lines (61 loc) · 1.41 KB
/
B_Taisia_and_Dice.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
#include <bits/stdc++.h>
using namespace std;
int main(){
// sum of all original dice = s
// sum of alter dice with max no missing = r
int tt;
cin >> tt;
while(tt--){
int n ,s ,r;
cin >> n >> s >> r;
int last_element = s-r;
// vec.push_back(ls);
vector<int> vec(n-1);
vec.push_back(last_element);
for(int i =0; i<n-1; i++){
// 4 9 5
// _ _ _ _4 = 9
// _ _ _ = 5
// 5 17 11
// _ _ _ _ _6 = 17
// _ _ _ _ = 11
// 1<11;
// 1+6
// 2<11
// 1+2+6
// 3<6
// 1+2+3+6
// 4<6
// 1+2+3+5+6 = 17
// 5 20 15
// _ _ _ _ _5 = 20
// _ _ _ _ = 15
// 1<15
// 1+5
// 2<15
// 1+2+5
// 3<15
// 1+2+3+5
// 4<15
// 1+4+5+5+5 = 17
// starting number be 1
vec[i] =1 ;
r= r-1;
}
int i=0;
while(r!=0){
if(vec[i]<last_element){
vec[i]++;
r--;
}
else{
i++;
}
}
// sort(vec.begin(),vec.end());
for(int i =0; i<vec.size(); i++){
cout << vec[i] << " ";
}
cout << endl;
}
}