-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodeforces_aug20_.cpp
More file actions
68 lines (65 loc) · 1.3 KB
/
Copy pathcodeforces_aug20_.cpp
File metadata and controls
68 lines (65 loc) · 1.3 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
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <bits/stdc++.h>
using namespace std;
int main()
{
int samples;
cin >> samples;
while (samples--)
{
unsigned int n;
long long unsigned int i;
long long unsigned int k,b,s;
long long unsigned int sum;
cin>>n>>k>>b>>s;
long long unsigned int last=b*k+k-1;
long long unsigned int left_sum = s-last;
long long unsigned int left_count=0;
long long unsigned int left_rem=0;
if(k==1){
left_count=left_sum/1;
left_rem=left_sum%1;
}
else{
left_count=left_sum/(k-1);
left_rem=left_sum%(k-1);
}
if(s<=last &&s/k==b){
last=s;
cout<<last<<" ";
for ( i = 0; i < n-1; i++)
{
cout<<0<<" ";
}
cout<<endl;
}
else{
if(left_rem!=0){
left_count++;
}
if(n<left_count){
cout<<-1<<endl;
}
else{
if(left_rem!=0){
cout<<left_rem<<" ";
for ( i = 1; i < left_count; i++)
{
cout<<k-1<<" ";
}
}
else {
for ( i = 0; i < left_count; i++)
{
cout<<k-1<<" ";
}
}
for ( i = 1; i < n-left_count; i++)
{
cout<<0<<" ";
}
cout<<last<<endl;
}
}
}
return 0;
}