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
129
130
131
132
133
134
135
136
137
138
139
#include <bits/stdc++.h>

#define _2137 0
#define pb push_back
#define ff first
#define ss second
#define inf 1000007

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;



using namespace std;

int main() {

    vector <int> ans;

    uint A,B,C,a,b,c;

    scanf("%d %d %d %d %d %d",&A,&B,&C,&a,&b,&c);
    uint a1=A-a,b1=B-b,c1=C-c;

    ans.resize(2*C+1,inf);

    ans[a]=0;
    ans[b]=0;
    ans[c]=0;

    //from back to front

    if(c>=b1){
        if(1<ans[B]) ans[B]=1;

        if(1<ans[c-b1]) ans[c-b1]=1;
        if(c>=b1+a1){
            if(2<ans[c-b1-a1]) ans[c-b1-a1]=2;
        }
    }
    /*    
    if(c>=a1){
        if(1<ans[A]) ans[A]=1;

        if(1<ans[c-a1]) ans[c-a1]=1;
    }
    */
    //recursive
    int temp1c,temp1a=A,temp1b=b,temp1b1=b1,moves,
    temp2b,temp2c=c,temp2c1=c1;
    if(a1!=0) {
        if(c1>=a1){
            if(1<ans[c+a1]) ans[c+a1]=1;
        }
        else{
            if(1<ans[c-a1]) ans[c-a1]=1;
        }
        if(b1>=a1){
            if(1<ans[b+a1]) ans[b+a1]=1;
        }
        else{
            if(1<ans[b-a1]) ans[b-a1]=1;
        }
        moves=1;
        temp1c=c-a1;
        temp2b=b-a1;
    }
    else {
        temp1c=c;
        temp2b=b;
        moves=0;
    }

    while(temp1c>=0 && temp1b1>=0){
        temp1c-=temp1a;
        if(moves<ans[temp1c]) ans[temp1c]=moves;
        if(moves<ans[temp1c+2*a1]) ans[temp1c+2*a1]=moves;
        ++moves;
        temp1b1-=temp1a;
        temp1b+=temp1a;
        if(moves<ans[temp1b]) ans[temp1b]=moves;
        if(moves<ans[temp1b+a1]) ans[temp1b+a1]=moves;
        ++moves;

    }
    if(a!=0) moves=1;
    else moves=0;
    
    while(temp2b>=0 && temp2c1>=0){
        temp2b-=temp1a;
        if(moves<ans[temp2b]) ans[temp2b]=moves;
        if(moves<ans[temp2b+2*a1]) ans[temp2b+2*a1]=moves;
        ++moves;
        temp2c1-=temp1a;
        temp2c+=temp1a;
        if(moves<ans[temp2c]) ans[temp2c]=moves;
        if(moves<ans[temp2c+a1]) ans[temp2c+1]=moves;
        ++moves;

    }


    /*
    if(b>=a1){
        if(1<ans[A]) ans[A]=1;

        if(1<ans[b-a1]) ans[b-a1]=1;
    }
    */
    //from front to back

    if(a<=b1){
        if(1<ans[0]) ans[0]=1;

        if(1<ans[b+a]) ans[b+a]=1;

    }

    if(a<=c1){
        if(1<ans[0]) ans[0]=1;

        if(1<ans[c+a]) ans[c+a]=1;
    }
    
    if(b<=c1){
        if(1<ans[0]) ans[0]=1;
        if(1<ans[c+b]) ans[c+b]=1;
    }


    for(int i=0;i<=C;++i){
        if(ans[i]==inf) printf("-1 ");
        else printf("%d ",ans[i]);
    }


	 return _2137;
}