37,719
社区成员
发帖
与我相关
我的任务
分享
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from itertools import combinations_with_replacement as CBR
n=5
cb=CBR(range(n),2)
print(*(filter (lambda t:t[0]+t[1]==4,cb)),sep='\n')
total=4
money=[1,2]
results=[]
for i in range(total/money[0]+1):
result=[i]
for ii in range(total/money[1]+1):
if i*money[0]+ii*money[1]==total:
result.append(ii)
results.append(result)
print(results)