都说数据这儿高手多,请高手帮助提供一个思路,方法

cy20090503 2010-09-25 05:28:26
我们有一种固定60宽度的半成品,想将它裁成如下宽度的产品,
要确保相同材质,相同厚度的基础情况下再考虑宽度
确保,余料最少,用有半成品个数最少,

也就是说,用5.6,10,20这些数去拼成接近60的数,最少能拼多少个这种数,成拼成的和越接近60越好。


材质 厚度 宽度
F042 2.5 5.6
F042 2.5 5.6
F042 2.5 5.6
F042 2.5 5.6
W001 2.5 10
W001 2.5 10
W001 2.5 10
W001 2.5 10
W001 2.5 10
W001 2.5 10
W001 2.5 10
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 15
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 20
W001 2.5 25
W001 2.5 25
W001 2.5 25
W001 2.5 25
W001 2.5 25
W001 2.5 25
W001 2.5 25
W001 2.5 25
W001 2.5 25
W001 2.5 25
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 6.3
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 2.5 9.7
W001 3 10
W001 3 10
W001 3 10
W001 3 10
W001 3 10
W001 3 15
W001 3 15
W001 3 15
W001 3 15
W001 3 15
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 3 20
W001 4 15
W001 4 15
W001 4 15
W001 4 15
W001 4 15
W001 4 15
W001 4 15
W001 4 15
W001 4 15
W001 4 15
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 6
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 8.1
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
W001 4 9.7
...全文
101 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
cy20090503 2010-09-27
[Quote=引用 3 楼 jstoic 的回复:]

专业刷屏题目
[/Quote]
不要瞎说话,没在诚意你可不用打这几个字,如果这样你也算是刷屏了
回复
playwarcraft 2010-09-25
select id=identity(int,1,1),part,hou,kuan=60,priority=0,flag=0 into #tmp from T

--==>>>>

-- kuan栏位的数据类型换一下
select id=identity(int,1,1),part,hou,kuan=60.0 ,priority=0,flag=0 into #tmp from T

回复
playwarcraft 2010-09-25

--数据不多的话,试试看游标能不能跑。

Create table T(part varchar(10), hou numeric(18,2), kuan numeric(18,2))
insert into T
select 'F042', 2.5, 5.6
union all select 'F042', 2.5, 5.6
union all select 'F042', 2.5, 5.6
union all select 'F042', 2.5, 5.6
union all select 'W001',2.5,10
union all select 'W001',2.5,10
union all select 'W001',2.5,20
union all select 'W001',2.5,20
union all select 'W001',2.5,25
union all select 'W001',2.5,25
union all select 'W001',2.5,25
union all select 'W001',2.5,25
union all select 'W001',2.5,25
union all select 'W001',2.5 ,6.3
union all select 'W001',2.5, 6.3
union all select 'W001',2.5 ,6.3
GO
select id=identity(int,1,1),part,hou,kuan,number=0 into #T from T order by part,hou,kuan desc
select id=identity(int,1,1),part,hou,kuan=60,priority=0,flag=0 into #tmp from T

declare @part varchar(10),@hou numeric(18,2), @kuan numeric(18,2) , @use numeric(18,2),@left numeric(18,2),@id1 int,@id2 int
declare c1 cursor for
select id,part,hou,kuan from #T order by part,hou,kuan desc
open c1
fetch next from c1 into @id1,@part,@hou,@kuan
while @@fetch_status=0
begin
select @left=kuan-@kuan, @id2 =id
from (select top 1 * from #tmp where part=@part and hou=@hou and kuan>=@kuan order by priority desc,kuan,id ) A

update #T set number=@id2 where id=@id1
Update #tmp set kuan=@left,priority=1 where id=@id2

fetch next from c1 into @id1,@part,@hou,@kuan

end
close c1
deallocate c1

GO
-- number栏位指是否用同一块60的半成品
select * from #T order by number
/*
id part hou kuan number
----------------------------------------------------
1 F042 2.50 5.60 1
2 F042 2.50 5.60 1
3 F042 2.50 5.60 1
4 F042 2.50 5.60 1
5 W001 2.50 25.00 5
6 W001 2.50 25.00 5
12 W001 2.50 10.00 5
13 W001 2.50 10.00 6
7 W001 2.50 25.00 6
8 W001 2.50 25.00 6
9 W001 2.50 25.00 7
10 W001 2.50 20.00 7
14 W001 2.50 6.30 7
15 W001 2.50 6.30 7
16 W001 2.50 6.30 8
11 W001 2.50 20.00 8
*/

GO
drop table T
drop table #T
drop table #tmp
回复
pengpeng409 2010-09-25
学习。。。
回复
SQLCenter 2010-09-25
半成品是刚性不可塑的吧
回复
SQLCenter 2010-09-25
这个题目有点意思,瞄瞄。
回复
zsh0809 2010-09-25
回复
Rotel-刘志东 2010-09-25
期待高手了
回复
ws_hgo 2010-09-25
回复
jstoic 2010-09-25
专业刷屏题目
回复
dawugui 2010-09-25
...............

非SQL内容,帮顶。
回复
hao1hao2hao3 2010-09-25
晕了。
回复
相关推荐
发帖
疑难问题
创建于2007-09-28

2.1w+

社区成员

MS-SQL Server 疑难问题
申请成为版主
帖子事件
创建了帖子
2010-09-25 05:28
社区公告
暂无公告