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()
# ==========================
相关推荐
明知道的博客1 小时前
解决WSL环境下DeepSeek-OCR运行时内存不足问题
python·ocr·deepseek·deepseek-ocr
FreeCode1 小时前
LangGraph1.0智能体开发:Graph API概念与设计
python·langchain·agent
test管家2 小时前
如何在Python中使用SQLite数据库进行增删改查操作?
python
yangmf20404 小时前
APM(三):监控 Python 服务链
大数据·运维·开发语言·python·elk·elasticsearch·搜索引擎
yangmf20404 小时前
APM(二):监控 Python 服务
大数据·python·elasticsearch·搜索引擎
CoderJia程序员甲4 小时前
GitHub 热榜项目 - 日榜(2025-11-23)
python·开源·github·mcp
AI爱好者4 小时前
WordPress保卫战:用Python分析日志并封禁恶意爬虫
python
nvd114 小时前
Gidgethub 使用指南
开发语言·python
___波子 Pro Max.5 小时前
Python模块导入详解与最佳实践
python
CNRio6 小时前
ZUC国密算法深度研究:原理、实现与应用(Python、Rust)
python·算法·rust