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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <bits/stdc++.h>
using namespace std;
int tab[100005] {};

int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

int A,B,C,la,lb,lc,mini,maxi,x=0,i=0;

cin>>A>>B>>C;
cin>>la>>lb>>lc;

mini=max(0,la+lb+lc-B-C);
maxi=min(C,la+lb+lc);

for (int i=0;i<mini;i++)
{tab[i]=-1;}

for (int i=maxi+1;i<=C;i++)
{tab[i]=-1;}

for (int i=mini;i<=maxi;i++)
{tab[i]=INT_MAX;}

if (lb<=(A+C-la-C))
x=max(0,lb-A+la-C+lc);
i=1;
while (x+A<=maxi)
{x=x+A;
tab[x]=min(i*2,tab[x]);}

x=lc;
while (x+A<=maxi)
{x=x+A;
i++;
tab[x]=min(i*2,tab[x]);}

x=lc-(A-la);
i=0;
while (x<=maxi) 
{x=x+A;}
while (x-A<=mini)
{tab[x-A]=min(tab[x-A],(i*2)+1);
i++;}

x=lc-(B-lb);
i=0;
while (x<=maxi) 
{x=x+B;}
while (x-B<=mini)
{tab[x-B]=min(tab[x-B],(i*2)+1);
i++;}

x=lc;
i=0;
while (x-A>=mini)
{x=x-A;
i++;
tab[x]=min(i*2,tab[x]);}

x=lc;
i=0;
while (x+B<=maxi)
{x=x+B;
i++;
tab[x]=min(i*2,tab[x]);}

x=lc;
i=0;
while (x-B>=mini)
{x=x-B;
i++;
tab[x]=min(i*2,tab[x]);}

x=lb;
i=0;
while (x-A>=mini)
{x=x-A;
i++;
tab[x]=min(i*2,tab[x]);}

x=lb;
i=0;
while (x+A<=maxi)
{x=x+A;
i++;
tab[x]=min(i*2,tab[x]);}

x=A;
i=0;
while (x-B>=mini)
{x=x-B;
i++;
tab[x]=min(i*2,tab[x]);}	

x=A;
i=0;
while (x-C>=mini)
{x=x-C;
i++;
tab[x]=min(i*2,tab[x]);}	

tab[min(A,la+lb)]=1;
tab[min(A,la+lc)]=1;
tab[min(B,la+lb)]=1;
tab[min(B,lb+lc)]=1;
tab[min(C,la+lc)]=1;
tab[min(C,lb+lc)]=1;
tab[max(0,la-(B-lb))]=1;
tab[max(0,la-(C-lc))]=1;
tab[max(0,lb-(A-la))]=1;
tab[max(0,lb-(C-lc))]=1;
tab[max(0,lc-(A-la))]=1;
tab[max(0,lc-(B-lb))]=1;

for (int i=mini;i<=maxi;i++)
{if (tab[i]==INT_MAX) {tab[i]=3;}}

tab[la]=0,tab[lb]=0,tab[lc]=0;

for (int i=0;i<=C;i++)
{cout<<tab[i]<<" ";}

return 0;
}