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
#include<bits/stdc++.h>
using namespace std;
int A, B, C;
int a,b,c;
map<tuple<int,int, int>, int> m;
int mini[100100];
void search(int x, int y, int z, int ile)
{
	if(m[make_tuple(x, y,z )])
	{
		if(m[make_tuple(x, y, z)]<=ile&&m[make_tuple(x, y, z)]!=0)
			return;
	}	
	//cout<<x<<" "<<y<<" "<<z<<"\n";
	m[make_tuple(x, y, z)]=ile;
	mini[x]=min(mini[x], ile);
	mini[y]=min(mini[y], ile);
	mini[z]=min(mini[z], ile);
	if(y<B)
	{
		int nx=0, ny=y;
		ny+=x;
		if(ny>B)
		{
			nx=ny-B;
			ny-=(ny-B);
		}
		search(nx, ny, z, ile+1);//przelewanie x->y
	}
	if(z<C)
	{
		int nx=0, nz=z;
		nz+=x;
		if(nz>C)
		{
			nx=nz-C;
			nz-=(nz-C);
		}
		search(nx, y, nz, ile+1);//przelewanie x->z
	}
	if(z<C)
	{
		int ny=0, nz=z;
		nz+=y;
		if(nz>C)
		{
			ny=(nz-C);
			nz-=(nz-C);
		}
		search(x, ny, nz, ile+1);//przelewanie y->z
	}
	if(y<B)
	{
		int ny=y, nz=0;
		ny+=z;
		if(ny>B)
		{
			nz=(ny-B);
			ny-=(ny-B);
		}
		search(x, ny, nz, ile+1); //przelewanie z->y
	}
	if(x<A)
	{
		int nx=x, nz=0;
		nx+=z;
		if(nx>A)
		{
			nz=(nx-A);
			nx-=(nx-A);
		}
		search(nx, y, nz, ile+1); //przelewanie z->x
	}
	if(x<A)
	{
		int nx=x, ny=0;
		nx+=y;
		if(nx>A)
		{
			ny=(nx-A);
			nx-=(nx-A);
		}
		search(nx, ny, z, ile+1);//przelewanie y->x
	}
}
int main()
{
	cin>>A>>B>>C>>a>>b>>c;
	for(int i=0;i<C+1;i++)
	mini[i]=1e9;
	search(a, b, c, 1);
	for(int i=0;i<C+1;i++)
	{
		if(mini[i]==1e9)
		cout<<-1<<" ";
		else
		cout<<mini[i]-1<<" ";
	}
	return 0;
}