I**A 发帖数: 2345 | 1 for any integer x between 1 to 27
find 3 numbers from (0 ..9) and the sum of them equals x.
the 3 numbers need not be distinct
for instance, 5+5+5=x |
r****o 发帖数: 1950 | 2 for i=0..9
for j=0..9
if 0<-(27-i-j)<=9 print i,j,27-i-j
有更好的方法吗?
【在 I**A 的大作中提到】 : for any integer x between 1 to 27 : find 3 numbers from (0 ..9) and the sum of them equals x. : the 3 numbers need not be distinct : for instance, 5+5+5=x
|
s******t 发帖数: 2374 | |
s******t 发帖数: 2374 | 4 看刚才某个题目有感:
如果只要给一个答案: 查表!
【在 r****o 的大作中提到】 : for i=0..9 : for j=0..9 : if 0<-(27-i-j)<=9 print i,j,27-i-j : 有更好的方法吗?
|
I**A 发帖数: 2345 | 5 赞,你这个很好了,2700嘛才!
【在 r****o 的大作中提到】 : for i=0..9 : for j=0..9 : if 0<-(27-i-j)<=9 print i,j,27-i-j : 有更好的方法吗?
|
g**********1 发帖数: 1113 | 6 先把数除3,遍历result1 to 9,然后这个过程中,把(total- count)/2,遍历
result2 to count.也就是说,先确定最大的数的范围,然后确定其次大的数的范围,
然后随便遍历一下,就都出来了,可以把结果存在一个2维数组里面。 |
I**A 发帖数: 2345 | 7 写程序写程序。。
【在 g**********1 的大作中提到】 : 先把数除3,遍历result1 to 9,然后这个过程中,把(total- count)/2,遍历 : result2 to count.也就是说,先确定最大的数的范围,然后确定其次大的数的范围, : 然后随便遍历一下,就都出来了,可以把结果存在一个2维数组里面。
|
s******t 发帖数: 2374 | 8 你们不觉得1-27这个范围太小么
表格:
1: 0, 0, 1
2: 0, 1, 1
3: 1,1,1
4: 1,1,2
5, 1, 1,3
6, 1, 1,4
。。。。。
27, 9,9,9
【在 I**A 的大作中提到】 : 写程序写程序。。
|
I**A 发帖数: 2345 | 9 童鞋,是从0-9,0呢?0呢?
【在 s******t 的大作中提到】 : 你们不觉得1-27这个范围太小么 : 表格: : 1: 0, 0, 1 : 2: 0, 1, 1 : 3: 1,1,1 : 4: 1,1,2 : 5, 1, 1,3 : 6, 1, 1,4 : 。。。。。 : 27, 9,9,9
|
s******t 发帖数: 2374 | 10 faint。我该睡觉了。我洗洗睡了
【在 I**A 的大作中提到】 : 童鞋,是从0-9,0呢?0呢?
|
|
|
I**A 发帖数: 2345 | 11 wave~~~
【在 s******t 的大作中提到】 : faint。我该睡觉了。我洗洗睡了
|
m****n 发帖数: 589 | 12 可不可以递归?然后用一个global的数组?
【在 I**A 的大作中提到】 : for any integer x between 1 to 27 : find 3 numbers from (0 ..9) and the sum of them equals x. : the 3 numbers need not be distinct : for instance, 5+5+5=x
|
s******t 发帖数: 2374 | 13 随便举个例子。
18 = 9+9+0
18 = 9+8+1
18 = 9+7+2
题目的要求是什么,是需要listout每个可能性么? |
g*****t 发帖数: 42 | 14 print x/3, (x+1)/3, (x+2)/3 |
I**A 发帖数: 2345 | 15 nod, all combination
the original question is this one
"Find all numbers in the range 1...999999, where the sum of first 3 digits are same as last three digits"
【在 s******t 的大作中提到】 : 随便举个例子。 : 18 = 9+9+0 : 18 = 9+8+1 : 18 = 9+7+2 : 题目的要求是什么,是需要listout每个可能性么?
|
I**A 发帖数: 2345 | 16 请问大家
这道题
除了分解1-27之间任何一个数成三个数(0-9)之外
有没有别的好办法?
are same as last three digits"
【在 I**A 的大作中提到】 : nod, all combination : the original question is this one : "Find all numbers in the range 1...999999, where the sum of first 3 digits are same as last three digits"
|