Print? /*
How many coins can be combined?
Calculation of the value equal to the capacity of multiple backpacks
*/
# Include <stdio. h>
# Include <string. h>
Struct node
{
Int w, v, c;
} Wu [1, 150];
Int n, m;
Int dp [101000];
Void cpack (int c, int ww, int * d, int w)
{
Int j;
For (j = c; j <= w; j ++)
{
If (d [j-c] + ww)> d [j])
D [j] = d [j-c] + ww;
}
}
Void znpack (int c, int ww, int * d, int w)
{
Int j;
For (j = w; j> = c; j --)
{
If (d [j] <(d [j-c] + ww ))
D [j] = d [j-c] + ww;
}
}
Void mpack (int c, int ww, int nn, int * d, int w)
{
If (c * nn> = w)
{
Cpack (c, ww, d, w );
Return;
}
Int k = 1;
While (k <nn)
{
Znpack (k * c, k * ww, d, w );
Nn = nn-k;
K = k * 2;
}
Znpack (nn * c, nn * ww, d, w );
}
Int main ()
{
Int I, ret;
While (scanf ("% d", & n, & m), n + m)
{
Ret = 0;
Memset (dp, 0, sizeof (dp ));
For (I = 0; I <n; I ++)
{
Scanf ("% d", & wu [I]. w );
Wu [I]. v = wu [I]. w;
}
For (I = 0; I <n; I ++)
{
Scanf ("% d", & wu [I]. c );
}
For (I = 0; I <n; I ++)
{
If (wu [I]. c)
Mpack (wu [I]. w, wu [I]. v, wu [I]. c, dp, m );
}
For (I = 1; I <= m; I ++)
{
If (dp [I] & dp [I]! = Dp [I-1]) ret ++;
}
Printf ("% d \ n", ret );
}
Return 0;
}
/*
How many coins can be combined?
Calculation of the value equal to the capacity of multiple backpacks
*/
# Include <stdio. h>
# Include <string. h>
Struct node
{
Int w, v, c;
} Wu [1, 150];
Int n, m;
Int dp [101000];
Void cpack (int c, int ww, int * d, int w)
{
Int j;
For (j = c; j <= w; j ++)
{
If (d [j-c] + ww)> d [j])
D [j] = d [j-c] + ww;
}
}
Void znpack (int c, int ww, int * d, int w)
{
Int j;
For (j = w; j> = c; j --)
{
If (d [j] <(d [j-c] + ww ))
D [j] = d [j-c] + ww;
}
}
Void mpack (int c, int ww, int nn, int * d, int w)
{
If (c * nn> = w)
{
Cpack (c, ww, d, w );
Return;
}
Int k = 1;
While (k <nn)
{
Znpack (k * c, k * ww, d, w );
Nn = nn-k;
K = k * 2;
}
Znpack (nn * c, nn * ww, d, w );
}
Int main ()
{
Int I, ret;
While (scanf ("% d", & n, & m), n + m)
{
Ret = 0;
Memset (dp, 0, sizeof (dp ));
For (I = 0; I <n; I ++)
{
Scanf ("% d", & wu [I]. w );
Wu [I]. v = wu [I]. w;
}
For (I = 0; I <n; I ++)
{
Scanf ("% d", & wu [I]. c );
}
For (I = 0; I <n; I ++)
{
If (wu [I]. c)
Mpack (wu [I]. w, wu [I]. v, wu [I]. c, dp, m );
}
For (I = 1; I <= m; I ++)
{
If (dp [I] & dp [I]! = Dp [I-1]) ret ++;
}
Printf ("% d \ n", ret );
}
Return 0;
}