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()
# ==========================
相关推荐
Cooper252 分钟前
DDC 命令成功但屏幕不动:用 gamma 表重做亮度映射
python·mac
师夷长技以自愈30 分钟前
手搓 AI Agent 第 7 篇:菜做砸了别硬炒——错误分类 + 双账本熔断
人工智能·python
用户9562562542939 分钟前
15 分钟社媒简报 Agent:我只用了搜索和模型两步
python·api
Dumbness42 分钟前
关键词回复里写了 {订单号},群机器人整条消息都炸了
python·微信
调接口的阿光43 分钟前
调用对话接口时输出被截断怎么办:先看 finish_reason,再决定是续写一次、缩小范围,还是换成更短的格式(Python)
人工智能·python
Cooper251 小时前
单文件 Flask 跑通微信服务器校验:先跑通再谈工程化
python·flask
Cooper251 小时前
三源热榜去重加 AI 摘要:URL 唯一键踩出的三个坑
前端·python
用户4019925568611 小时前
多源异构 B2B 公开需求信号去重与企业实体证据链存储设计(64-bit SimHash 分桶 + Jaccard)
python
aifannihao2 小时前
GitHub Actions 锁文件实测:6 个 uses 只锁住 2 个
python·ci/cd·标准库·供应链安全·github actions
2601_967980112 小时前
使用gensim处理文本(1)语料库与词向量空间
python·自然语言处理·gensim·词向量·文本分析