2020年全國高校計算機能力挑戰賽Python程式設計初賽
阿新 • • 發佈:2020-11-30
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 inrange(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)