2020年全国高校计算机能力挑战赛Python程序设计初赛

######说明:答案仅提供参考

部分选择题:

1、Python在内存中存储了每个对象的引用计数(reference count)。如果计数值变成0,关于相应的对象会发生变化,描述错误的是?(B)

  A. 相应的对象消失

  B. 相应的对象仍然存在

  C. 分配给该对象的内存会释放出来

  D. 相应的对象占用的空间会移交给操作系统

2、在Unix系统中,以下关于可执行Python脚本文件说法正确的是?(A)

  A. 脚本文件的模式必须是可执行的

  B. 第一行必须以#(#!/usr/local/bin/python)开头

  C. 脚本文件都可以直接执行

  D. 以上说法都不正确

4、以下英文单词中,不是Python保留字的是(A)

  A. do

  B. finally

  C. with

  D. in

8、以下哪个函数可以随机化列表中的元素(C)

  A. init

  B. new

  C. random

  D. shuffle

10、以下哪个不是Python语言的标准库(D)

  A. datetime

  B. random

  C. sys

  D. graph

13、在Python中,a=0011 1100,b=0000 1101,表达式a&b的结果是(A)

  A. 0000 1100

  B. 0011 1101

  C. 0011 0001

  D. 1100 0011

所有大题:

a,b = input().strip().split()
count = 0
x_ = [-1,-1,-1]
for i in range(int(a)+1,int(b)):
    if i*2 % 5 ==0:
        x_[count] = i
        count += 1
    if count > 2:
        break
print(x_[0],x_[1],x_[2])

 

a,b = input().split()
x = list(map(int,input().split()))
temp_max = x[0]*x[1]*x[2]
temp_index = 0
for i in range(0,len(x)-2):
    v = x[i] * x[i + 1] * x[i + 2]
    if v > temp_max:
        temp_max = v
        temp_index = i
print(temp_max,temp_index+1)

 

str1 = input()
judge = "_1234.exe"
count = 0
num_list = []
for i in range(0,len(str1)-len(judge)+1):
    if str1[i:i+len(judge)] == judge:
        count += 1
        num_list.append(i)

if count == 0:
    print(count)
else:
    print(count,end=" ")
    for j in num_list:
        print(j,end=" ")

n = int(input().strip())
metrix = []
for i in range(n):
    metrix.append(list(map(int,input().strip().split())))

length = 0
I = -1
J = -1
tag = 0
for j in range(1,n-1): #遍历每一行
    temp_length = 0
    temp_i = -1
    temp_j = -1
    for k in range(n): #遍历每一列
        if metrix[j][k] > metrix[j-1][k] and metrix[j][k] > metrix[j+1][k]:
            temp_length += 1
            temp_i = j
            temp_j = k
            if temp_length > length:
                length = temp_length
                I = temp_i
                J = temp_j
                tag = 1 #标记更新
        else:
            temp_length = 0
            temp_i = -1
            temp_j = -1
    if tag == 1:
        J = J - length + 1
        tag = 0

for j in range(1,n-1): #遍历每一列
    temp_length = 0
    temp_i = -1 #代表行
    temp_j = -1 #代表列
    for k in range(n): #遍历每一行
        if metrix[k][j] > metrix[k][j-1] and metrix[k][j] > metrix[k][j+1]:
            temp_length += 1
            temp_i = k
            temp_j = j
            if temp_length > length:
                length = temp_length
                I = temp_i
                J = temp_j
                tag = 1
        else:
            temp_length = 0
            temp_i = -1
            temp_j = -1
    if tag == 1:
        I = I - length + 1
        tag = 0

if length == 0:
    print(0,-1,-1)
else:
    print(length,I+1,J+1)

 

posted @ 2020-12-02 09:17  云才哥  阅读(3697)  评论(0编辑  收藏  举报