2022 8 25
2022/8/26 6:55:23
本文主要是介绍2022 8 25,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
只做了一个组队题目https://www.lanqiao.cn/problems/604/learning/
报错是因为s1,s2里面的内容被更改,于是超出列表范围了。
具体的周末整理的时候再说。
import os import sys s1 = [97, 92, 0, 0, 89, 82, 0, 0, 0, 95, 0, 0, 94, 0, 0, 0, 98, 93, 0, 0] s2 = [90, 90, 85, 0, 0, 83, 86, 0, 97, 0, 99, 0, 0, 91, 83, 0, 0, 83, 87, 0, 99] s3 = [0, 96, 0, 0, 97, 0, 0, 96, 89, 0, 96, 0, 0, 87, 98, 0, 99, 92, 0, 96] s4 = [0, 0, 0, 80, 0, 0, 87, 0, 0, 0, 97, 93, 0, 0, 97, 93, 98, 96, 89, 95] s5 = [0, 0, 93, 86, 0, 0, 90, 0, 0, 0, 0, 98, 0, 0, 98, 86, 81, 98, 92, 81] s = [s1, s2, s3, s4, s5] t_s = [] index = 0 for i in range(5): copyS = s.copy()[i] for j in range(5): index = copyS.index(max(copyS)) t_s.append(index) copyS.remove(copyS[index]) print(t_s) temp = 0 # lis=[[] for i in range(5)] # print(lis) # for i in range(0,1): # for j in range(0,1): # lis[i][j]=t_s[i*5+j+1] # print(lis) result = [] for y in range(0, 5): # 控制行 for x in range(0, 5): # 控制列 if x == 0: result.append([]) result[y].append(t_s[x + y * 5]) # 这里的3是由控制列长度决定。是为了使结果按原顺序变形,避免混乱。 print(result) anchor = [0] * 5 best = 0 sth = 0 finalName = [] s1 = [97, 92, 0, 0, 89, 82, 0, 0, 0, 95, 0, 0, 94, 0, 0, 0, 98, 93, 0, 0] s2 = [90, 90, 85, 0, 0, 83, 86, 0, 97, 0, 99, 0, 0, 91, 83, 0, 0, 83, 87, 0, 99] s3 = [0, 96, 0, 0, 97, 0, 0, 96, 89, 0, 96, 0, 0, 87, 98, 0, 99, 92, 0, 96] s4 = [0, 0, 0, 80, 0, 0, 87, 0, 0, 0, 97, 93, 0, 0, 97, 93, 98, 96, 89, 95] s5 = [0, 0, 93, 86, 0, 0, 90, 0, 0, 0, 0, 98, 0, 0, 98, 86, 81, 98, 92, 81] for i in result[0]: finalName.append(i) for j in result[1]: if(j in finalName): continue finalName.append(j) for k in result[2]: if(k in finalName): continue finalName.append(k) for l in result[3]: if(l in finalName): continue finalName.append(l) for m in result[4]: if(m in finalName): continue sth = s1[i]+s2[j]+s3[k]+s4[l]+s5[m] if(sth>best): best = sth finalName.remove(l) finalName.remove(k) finalName.remove(j) finalName.remove(i) print(best)
这篇关于2022 8 25的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-26大厂数据结构与算法教程:入门级详解
- 2024-12-26大厂算法与数据结构教程:新手入门指南
- 2024-12-26Python编程入门指南
- 2024-12-26数据结构高级教程:新手入门及初级提升指南
- 2024-12-26并查集入门教程:从零开始学会并查集
- 2024-12-26大厂数据结构与算法入门指南
- 2024-12-26大厂算法与数据结构入门教程
- 2024-12-26二叉树入门教程:轻松掌握基础概念与操作
- 2024-12-26初学者指南:轻松掌握链表
- 2024-12-26平衡树入门教程:轻松理解与应用