如何返回一个整数数组,该数组的总和等于php中的给定数字? [英] How do I return an integer array the sum of which equals to a given number in php?
本文介绍了如何返回一个整数数组,该数组的总和等于php中的给定数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
输入:在 1-15 或 64-79 范围内的任何数字,该数字是(1、2、4, 8、64)任意组合
Input: any number in 1-15 or 64-79 range which is a sum of either (1, 2, 4, 8, 64) in any combination
输出:此列表中的整数数组:( 1、2、4、8、64 ),其总和等于输入数字.
Output: an array of integers from this list: (1, 2, 4, 8, 64) the sum of which equals the input number.
例如
- 输入 72 ,输出 array(8,64)
- 输入 13 ,输出 array(1, 4,8)
- input 72, output array(8, 64)
- input 13, output array(1, 4, 8)
推荐答案
这篇关于如何返回一个整数数组,该数组的总和等于php中的给定数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文