第一题
import sys
str_list = [x for x in sys.stdin.readline().strip()]
K = int(len(str_list)/4)
for i in range(K+1):
if (i == 0):
j = 1
line = str_list[0]
while(j<=K):
line = line + str_list[j]
j = j+1
if (i == K):
j = 1
line = str_list[3*K]
while(j<=K):
line = line+str_list[3*K-j]
j=j+1
if(i!=0 and i!=K):
line = str_list[-i]
for j in range(K-1):
line = line + ' '
line = line+str_list[K+i]
print(line)
第二题
import sys
def panduan(lis):
if(len(lis)==0):
return 0
count = 0
if(len(lis)==1):
count =count+1
elif(lis[0] == 0 and lis[-1]==0):
count = count
elif(lis[0] == 0 and lis[-1]!=0):
count=count+1
elif(lis[0] != 0 and lis[-1] ==0):
count=count+1
else:
count =count+len(lis)
return count
num_list = [int(x) for x in sys.stdin.readline().strip()]
count = 0
for i in range(len(num_list)-1):
list1 = num_list[0:i+1]
list2 = num_list[i+1:]
count1 = panduan(list1)
count2 = panduan(list2)
count = count+count1*count2
print(count)
第三题
import sys
list1 = sys.stdin.readline().strip().split()
N = int(list1[0])
M = int(list1[1])
li_total = []
for i in range(N):
li = [int(x) for x in sys.stdin.readline().strip().split()]
li_total.append(li)
Max_usr = 0
for i in range(N):
count = 0
if i == M:
continue
if i in li_total[M]:
continue
else:
for j in li_total[M]:
if j in li_total[i]:
count = count + 1
if(count>Max_usr):
max_usr_id = i
Max_usr = count
print(max_usr_id)
第四题
import sys
def find(list2):
list_new = []
for i in range(len(list2)):
if i==0:
if list2[i]==list2[i+1]:
list_new.append(list2[i])
if i>=1 and i
if list2[i]>=list2[i-1] and list2[i]>=list2[i+1]:
list_new.append(list2[i])
if i==len(list2)-1:
if list2[i]==list2[i-1]:
list_new.append(list2[i])
return list_new
if __name__=="__main__":
list1 = sys.stdin.readline().strip()
num = int(list1)
list2 = [int(x) for x in sys.stdin.readline().strip().split()]
count = 1
while True:
list_new= find(list2)
if (len(list_new)>1):
count = count+1
list2 = list_new
elif(len(list_new)==1):
count = count+1
break;
else:
break
print(count)