L2-052 吉利矩阵

L2-052 吉利矩阵 - 团体程序设计天梯赛-练习集

这道题打表

打表部分被注释了

复制代码
n4 = [0,0,282, 2008, 10147, 40176, 132724, 381424, 981541, 2309384]
n3 = [0,0,21, 55, 120, 231, 406, 666, 1035, 1540]
n2 = [0,0,3, 4, 5, 6, 7, 8, 9, 10]
l,n = map(int,input().split())
if n == 2:
    print(n2[l])
elif n == 3:
    print(n3[l])
elif n == 4:
    print(n4[l])


# ==========================
#当n == 2时:
# def f():
#     ans = [0,0]
#     for  l in range(2,10):
#         cnt = 0
#         for a in range(0,min(l,9) + 1):
#             if l - a >= 0:
#                 cnt += 1
#         ans.append(cnt)
#     return ans
#n2 = f()
# ==========================
#当n == 3时:
# def f():
#     ans = [0,0]
#     for l in range(2,10):
#         cnt = 0
#         for a in range(0,min(l,9) + 1):
#             for b in range(0,min(l,9) + 1):
#                 for c in range(0,min(l,9) + 1):
#                     for d in range(0,min(l,9) + 1):
#                         if l - (a + b) >= 0 and l - (c + d) >= 0 and l - (a + c) >= 0 and l - (b + d) >= 0 and l - (2 * l - a - b - c - d) >= 0:
#                             cnt += 1
#         ans.append(cnt)
#     return ans
#n3 = f()
# ==========================
#当n == 4时:
# def f():
#     ans = [0,0]
#     for l in range(2,10):
#         cnt = 0
#         for a in range(0,min(l,9) + 1):
#             for b in range(0,min(l,9) + 1):
#                 for c in range(0,min(l,9) + 1):
#                     for d in range(0,min(l,9) + 1):
#                         for e in range(0,min(l,9) + 1):
#                             for f in range(0,min(l,9) + 1):
#                                 for g in range(0,min(l,9) + 1):
#                                     for h in range(0,min(l,9) + 1):
#                                         for i in range(0,min(l,9) + 1):
#                                             if l - (a + b + c) >= 0 and l - (d + e + f) >= 0 and l - (g + h + i) >= 0 and l - (a + d + g) >= 0 and l - (b + e + h) >= 0 and l - (c + f + i) >= 0 and l - (3 * l - a - b - c - d - e - f - g - h - i) >= 0:
#                                                 cnt += 1
#         ans.append(cnt)
#     return ans
#n4 = f()
# ==========================
相关推荐
郝学胜-神的一滴23 分钟前
Effective Python 条款 10 :海象运算符_=
开发语言·python·程序人生·开源
wuyk55525 分钟前
Python零基础入门第十四章:异常处理(try-except)
开发语言·python
2601_9620781927 分钟前
Appium+Python+pytest自动化测试框架详解
自动化测试·python·appium·pytest·移动应用
卷无止境4 小时前
智能体开发环境ADE浅析,编程工具的下一次范式跃迁
后端·python
2601_962300818 小时前
机器学习贴士:使用Python编写MapReduce
hadoop·python·机器学习·mapreduce·数据处理
xyz_CDragon8 小时前
GitHub上4个爆款AI开源Skill:拍照后不用P图,用Codex一键生成高级海报(附效果图+使用教程)
人工智能·python·github·codex·skill
weixin199701080168 小时前
[特殊字符]《跨境二手ERP对接Back Market:标准化API + 7~10工作日技术合规审核实录》(附Python源码)
开发语言·python·pandas
持敬chijing9 小时前
Python-数据类型-列表
开发语言·python·青少年编程
2601_9623010110 小时前
Python环境搭建及PyCharm破解使用技巧
python·pycharm·环境搭建·避坑技巧·破解使用
2601_9620994611 小时前
Python中的find()函数:用法和示例
python·字符串·索引·子字符串·find函数