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()
# ==========================
相关推荐
Irene19913 小时前
Python 卸载与安装(以卸载3.13.3,装3.13.13为例)
python
予早3 小时前
使用 pyrasite-ng 和 guppy3 做内存分析
python·内存分析
hef2888 小时前
如何生成特定SQL的AWR报告_@awrsqrpt.sql深度剖析单条语句性能
jvm·数据库·python
Jinkxs8 小时前
从语法纠错到项目重构:Python+Copilot 的全流程开发效率提升指南
python·重构·copilot
技术专家8 小时前
Stable Diffusion系列的详细讨论 / Detailed Discussion of the Stable Diffusion Series
人工智能·python·算法·推荐算法·1024程序员节
段一凡-华北理工大学8 小时前
【大模型+知识图谱+工业智能体技术架构】~系列文章01:快速了解与初学入门!!!
人工智能·python·架构·知识图谱·工业智能体
IT小Qi9 小时前
iperf3网络测试工具
网络·python·测试工具·信息与通信·ip
以神为界9 小时前
Python入门实操:基础语法+爬虫入门+模块使用全指南
开发语言·网络·爬虫·python·安全·web
xcjbqd09 小时前
Python API怎么加Token认证_JWT生成与验证拦截器实现
jvm·数据库·python
io_T_T9 小时前
如何调用google api 进行开发(使用免费版本)
python