2020年全国高校计算机能力挑战赛Python组区域赛

真被自己蠢到了,最后一题提交的时候忘记删除一个调试打印语句,凉凉,白给!
下面是考试的一些程序:

code1.py

nums = [int(i) for i in list(input().split(' '))]
N = nums[0]
M = nums[1]

total = []
for i in range(N+1,M):
    value = i * (i+1) * (i-1)
    if i % 5 == 0:
        total.append(i)
if (len(total) >= 3):
    print("{} {} {}".format(total[0],total[1],total[2]))
elif (len(total) == 1):
    print("{} {} {}".format(total[0],-1,-1))
elif (len(total) == 2):
    print("{} {} {}".format(total[0], total[1], -1))
else:
    print("{} {} {}".format(-1, -1, -1))

code2.py

nums = [int(i) for i in list(input().split(' '))]
N = nums[0]
M = nums[1]

numbers = [int(i) for i in list(input().split(' '))]
max_value =[]
count = []
# N=10,M=4时,i可以最大取值N[6],即0~6共7个数
# 1 2 3 4 5 6 7 8 9 10
for i in range(0,N-M+1):
    # 现在依次取M个数
    total = 0
    # 4*numbers[i] + (1+2+……M-1)
    true_value = M * numbers[i]
    for j in range(i,i+M):
        total += numbers[j]
    for j in range(M):
        true_value += j
    # 如果满足下式说明就是连续的M个数
    if true_value == total:
        max_value.append(total)
        count.append(i+1)
value = max(max_value)
for i in range(len(max_value)):
    if max_value[i] == value:
        print("{} {}".format(max_value[i],count[i]))

code3.py

string = input()
# abcadiasiqacdfgiikkg
max_strings = []
# 输入是'a'~'z'构成的,因此无需考虑特殊字符
max_child_string = ""
for i in range(len(string)-1):
    if ord(string[i]) <= ord(string[i+1]):
        max_child_string += string[i]
    else:
        max_strings.append(max_child_string)
        max_child_string = ""
lengths = []
for str1 in max_strings:
    lengths.append(len(str1))
max_length = max(lengths)
for str1 in max_strings:
    if len(str1) == max_length:
        # 现在需要判断str1在string中的位置
        if ord(string.split(str1)[-1][0]) >= ord(str1[-1]):
            str1 += string.split(str1)[-1][0]
            print(str1)

code4.py

nums = int(input())
totals = []
for i in range(nums):
    numbers = [int(i) for i in list(input().split(' '))]
    totals.append(numbers)
# 现在数据已经保存到totals里面
"""
    6
    0 3 0 0 1 1
    0 6 0 1 1 1 
    9 9 9 7 5 3
    6 5 3 5 3 3
    5 6 6 6 7 6
    3 4 4 5 5 5
"""
EOF = -1
# 边界不满足
for i in range(1,len(totals)-1):
    for j in range(1,len(totals[0])-1):
        """
            假设现在是第i+1行、第j+1列
            那么现在取得数据是totals[i][j]
            那么左边的数据是totals[i][j-1]
                右边的数据是totals[i][j+1]
                上面的数据是totals[i-1][j]
                下面的数据是totals[i+1][j]
        """
        if ((totals[i][j] < totals[i][j-1]) and (totals[i][j] < totals[i][j+1]) and (totals[i][j] < totals[i-1][j]) and (totals[i][j]) < totals[i+1][j]):
            print("{} {}".format(i+1,j+1))
            EOF = 1
            break
if EOF == -1:
    print("{} {}".format(-1,-1))

总结

①和模拟题相比,今年的选择器似乎更猥琐,考察到了好多奇奇怪怪的知识,甚至有些是我做外包这么久都没接触的!
②最后一题本就是最简单的,可是白给了,还是考试有点紧张,希望以后多次参加比赛,锻炼自己的能力!
③这个比赛赛题咋说呢!第一个编程很明显就有问题,希望赛事组以后能严谨一些!
④希望能进决赛吧~~~(最后一题难受)

猜你喜欢

转载自blog.csdn.net/weixin_43862765/article/details/110343582