日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

2019年第十届蓝桥杯 - 省赛 - C/C++大学B组 - A. 组队

發布時間:2024/5/6 c/c++ 53 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2019年第十届蓝桥杯 - 省赛 - C/C++大学B组 - A. 组队 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


Ideas

唉,大一的時候做這種題就是寫這種代碼,那時候覺得好垃圾。

大四了再做這種題還寫這種代碼,哈哈哈。

這題其實沒啥,就是讀文件,然后循環+check就完了,需要注意第一列時編號。

代碼

C++

#include <iostream> #include <cstdio>using namespace std; int team[20][6] = {{1, 97, 90, 0, 0, 0},{2, 92, 85, 96, 0, 0},{3, 0, 0, 0, 0, 93},{4, 0, 0, 0, 80, 86},{5, 89, 83, 97, 0, 0},{6, 82, 86, 0, 0, 0},{7, 0, 0, 0, 87, 90},{8, 0, 97, 96, 0, 0},{9, 0, 0, 89, 0, 0},{10, 95, 99, 0, 0, 0},{11, 0, 0, 96, 97, 0},{12, 0, 0, 0, 93, 98},{13, 94, 91, 0, 0, 0},{14, 0, 83, 87, 0, 0},{15, 0, 0, 98, 97, 98},{16, 0, 0, 0, 93, 86},{17, 98, 83, 99, 98, 81},{18, 93, 87, 92, 96, 81},{19, 0, 0, 0, 89, 92},{20, 0, 99, 96, 95, 81} };int main() {int ans = 0;for (int i = 0; i < 20; ++i) {for (int j = 0; j < 20; ++j) {if (j != i)for (int k = 0; k < 20; ++k) {if (k != j && k != i)for (int l = 0; l < 20; ++l) {if (l != k && l != j && l != i)for (int m = 0; m < 20; ++m) {if (m != l && m != k && m != j && m != i) {if (team[i][1] + team[j][2] + team[k][3] + team[l][4] + team[m][5] > ans)ans = team[i][1] + team[j][2] + team[k][3] + team[l][4] + team[m][5];}}}}}}cout << ans << endl;return 0; }

Python

if __name__ == '__main__':team = []with open("./team.txt", 'r') as fp:for line in fp.readlines():line = line.strip("\n").strip(',')team.append(eval(line))peoples, ans = len(team), 0for a in range(peoples):for b in range(peoples):if b != a:for c in range(peoples):if c != b and c != a:for d in range(peoples):if d != c and d != b and d != a:for e in range(peoples):if e != d and e != c and e != b and e != a:ans = max(ans, team[a][1] + team[b][2] + team[c][3] + team[d][4] + team[e][5])print(ans)

Answer:490

總結

以上是生活随笔為你收集整理的2019年第十届蓝桥杯 - 省赛 - C/C++大学B组 - A. 组队的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。