使用C语言,计算骨头的重量的问题,怎么采用C程序编写的代码运行的计算呢?

Problem Description
Ignatius found some bones in an ancient maze, which fascinated him a lot. However, when he picked them up, the maze began to shake, and Ignatius could feel the ground sinking. He realized that the bone was a trap, and he tried desperately to get out of this maze.
Suddenly, Ignatius heard a very very cool voice, and he recognize that it comes from Beelzebub feng5166:“I know that you like bone, and even I know your nick name is wishingbone. Today, I give you a chance to survive: there are N kinds of bones here and the number of each kind bone is enough, their weights are Wi pounds (1<=i<=N), your bag has a volume of M pounds, and I also know that you will spend 3 seconds time when you pick up any one bone. Today, you must fill up your bag as quick as you can, otherwise, the maze is your place of the death!”.
Oh, my god! Can the poor Ignatius survive? Please help him!
Note: You are guarantied that solution always exist for every test case.

Input
The input consists of multiple test cases. The first line of each test case contains two integers N and M (1 < N < 10; 0 < M < 1000000000), which denote the kinds of the bone and the capacity of the bag respectively. The next line give N integers W1…Wn (1<=wi<=100), which indicate the weights of bones
The input is terminated with two 0's. This test case is not to be processed.

Output
For each test case, print the minimal time Ignatius will spend when he can survive. One line per case.

Sample Input
2 20
1 5
0 0

Sample Output
12

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
如何用c语言循环结构编写这个程序?
1
怎样用C语言编写这个程序?
3
关于嵌入式操作系统的一个题目,编写一个c语言程序,其功能是将一个文本文件读出,然后再反序写回。
3
【C语言编写函数问题】从键盘输入一个浮点数,编写程序完成 如下功能:
0
树状节点的编号的一个算法的问题,看下怎么使用C语言编写程序来计算
0
在平面上不同障碍的安全高度的计算问题,采用C语言程序设计编写代码怎么做
0
计算机的登录记录的存储问题,怎么使用C语言的程序编写来实现的
0
数据结构的蜗牛旅行问题的计算方式,采用C语言的程序编写和设计的做法怎么实现
0
顶点的集合的计算的问题,怎么采用C语言的程序的编写的实现的方式
1
C语言设计简单计算问题
1
使用C语言进行一个月份的问题解决
1
几何形状的边的计算问题,怎么采用C语言的程序的编写的手段实现的?
0
日起的一个计算的问题,计算日期的编号采用C语言的程序的编写的技术?
0
请教节点的访问性的算法计算的问题,怎么采用C语言程序代码编写过程的思路实现
1
计算开车经过的路程的问题,怎么使用C语言代码编写程序的思想去实现呢?
0
通过算法估算计算机的价格问题,怎么采用C语言的程序代码编写的方式去实现的?
0
计算投放广告的花费的问题,怎么采用C语言程序设计的技术编写一个程序去实现的?
0
计算需要按的按钮最少的次数,怎么采用C语言程序代码编写程序的方式去解决这个问题的
0
递归函数编写计算求和的问题,怎么采用C语言的程序代码编写的过程去实现的呢?
0
计算PBD数的算法问题,怎么采用C语言的程序编写流程的思想去实现才能解决?