#a问:
#A中没有元素等于0,则A中元素的和和积的pair(sum, product),如果A中元素等于0,则输出为pair (null, null)
def FindSumAndProduct(li):
if(len(li) == 0):
return (None, None)
leng = len(li)
v = li[leng-1]
if(v == 0):
return (None, None)
sum = v
product = v
(tmpSum,tmpProduct) = FindSumAndProduct(li[:-1])
if tmpSum != None and tmpProduct != None:
sum += tmpSum
product *= tmpProduct
else:
return (None, None)
return (sum, product)