编程介的小学生
2019-04-29 22:08篮子中的宝石问题,利用C语言的程序的编写的思路实现的做法
Problem Description
Each of three baskets contains a certain number of marbles. You may move from one basket into another basket as many marbles as are already there, thus doubling the quantity in the basket that received the marbles. You must find a sequence of moves that will yield the same number of marbles in the three baskets. Moreover, you must achieve the goal in the smallest possible number of moves. Your program must also recognize the case in which there is no such sequence of moves.
Input
Each line of the input file will contain data for one instance of the problem: three positive integers, with one blank space separating adjacent integers. The three integers represent the initial numbers of marbles in the three baskets. The sum of the three integers will be at most 60.
Output
The output will begin with the initial configuration from the input. Thereafter, on successive lines, the number of marbles in the respective baskets will be printed after each move, concluding with the line in which the three numbers are identical. As stated above, the goal must be achieved in the smallest possible number of moves. (The correct output is not unique, however. There may be different sequences of moves which achieve the goal correctly in the smallest possible number of steps.) If there is no sequence of moves to achieve the goal, only the initial configuration will be printed. Each integer in the output will be right-justified in a field of width 4. Each instance of the problem will be concluded by a line of 12 equal signs.
Sample Input
6 7 11
15 18 3
5 6 7
Sample Output
6 7 11
6 14 4
12 8 4
8 8 8
15 18 3
12 18 6
12 12 12
5 6 7
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- 通过篮子过程传递勾选框
- html
- php
- 2个回答
- 在访问PSP时锁定网站电子商务篮子的最佳方式
- php
- 1个回答
- 填充Kiva篮子返回页面未找到
- curl
- api
- php
- 1个回答
- 向篮子项目添加数量是添加新项目
- session-variables
- php
- session
- 1个回答
- 将变量从篮子传递到Paypal以支付 - 增值税费用
- paypal
- php
- 2个回答