题目
这是菲菲的一道作业题,自从学了编程后,她就习惯性思维想用编程去解,用她的话说“编程不用动脑子”,其实数学方法更锻炼人的思维,欢迎大家聊聊此题的数学方法!
如果考试让带一样东西,那肯定是带电脑了!
菲菲视频讲解
答案
一共有2736种填法
如:
one: 9
two: 83
three: 674
four: 1250
one: 9
two: 84
three: 250
four: 1673
one: 9
two: 84
three: 253
four: 1670
one: 9
two: 84
three: 270
four: 1653
one: 9
two: 84
three: 273
four: 1650
one: 9
two: 84
three: 650
four: 1273
one: 9
two: 84
three: 653
four: 1270
one: 9
two: 84
three: 670
four: 1253
one: 9
two: 84
three: 673
four: 1250
……
代码
cnt =
forone inrange(10):
fortwo inrange(10,100):
forthree inrange(100,1000):
four =2016- one - two - three
print('one:',one)
print('two:',two)
print('three:',three)
print('four:',four)
print()
cnt = cnt +1
print(cnt)
领取专属 10元无门槛券
私享最新 技术干货