首页 > 其他 > 详细

超级书架2(计蒜客)

时间:2020-03-20 22:27:08      阅读:68      评论:0      收藏:0      [点我收藏+]

 

技术分享图片

 

 技术分享图片

 

 

 1 #include<iostream>
 2 using namespace std;
 3 int cow[25];
 4 int min_high = 0x3f3f3f3f;
 5 void dfs(int n,int len,int plus,int b)
 6 {
 7     if(plus>=b)
 8     {
 9        if(plus-b<min_high)
10            min_high = plus-b;
11     }
12     else
13     {
14         for(int i=n;i<=len;++i)
15         {
16             dfs(i+1,len,plus+cow[i],b);
17         }
18     }
19 }
20 int main()
21 {
22      int n,b;
23      cin>>n>>b;
24      for(int i=0; i<n;++i)
25      {
26          cin>>cow[i];
27      }
28      dfs(0,n,0,b);
29      cout<<min_high;
30      return 0;
31 } 

 

超级书架2(计蒜客)

原文:https://www.cnblogs.com/caxi/p/12535182.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!