Find another way longer than A-C

来源:互联网 发布:中国软件企业排名2016 编辑:程序博客网 时间:2024/06/08 07:13

I want to find a way like A->B, B-C , that is more than A-C .

Presume there are N { a1 , a2 , a3 , a4 …….}
First>>>
Select two elements , ai(A) and aj(C) ,and remove them from N
Second>>>
Select two elements am and an
if am = an
find the way aj - am - ai
else
remove them from N
Third >>>
We need to select an other elements from N , while Second , build the way like ai - am -….-an -aj until size of N is empty or find the elements like the way.

Fake code
for

0 0
原创粉丝点击