Blue Bridge Cup Question Record - 2020 Provincial Competition

A more comprehensive record of the 2020 provincial competition questions. The full text of this article uses Python to solve the questions, and the questions are all basic and simple questions.

1. Results statistics

insert image description here
Problem-solving code:

import os
import sys
n=int(input())
well=0
ok=0
for i in range(n):
    a=int(input())
    if a>=85:
        well+=1
        ok+=1
    elif a>=60:
        ok+=1
print("{:.0f}%".format(100*ok/n))
print("{:.0f}%".format(100*well/n))

2. Word Analysis

insert image description here
insert image description here
Problem solving:

import os
import sys

# 请在此输入您的代码
word=input()
a=0
b=[]
for i in word:
    c=word.count(i)
    if c>=a:
        a=c
for j in word:
    if word.count(j)==a:
        b.append(j)
b.sort()
print(b[0])
print(a)

3. Door plate making

insert image description here
answer:

import os
import sys

# 请在此输入您的代码
b=0
for i in range (1,2021):
  a=str(i).count('2')
  b+=a
print(b)

4. Number Triangle

insert image description here
insert image description here
answer:

import os
import sys

# 请在此输入您的代码
n = int(input())        #输入行数n
list_1 = [list(map(int,input().split())) for i in range(n)]       #依次录入数字三角形

list_2 = list_1[:]

for i in range(1,n):                                               #此处i代表循环n-1次 ---->n层中要走n-1步,例如第一层到第二层要走2-1=1步
    for j in range(0,i+1):                                         #此处代表i+1次,------>此处代表列
        if j == 0:                                                 #数字三角形中最左边那个数字只能由右上角哪一个走过来, 即:m[i][j]->m[i-1][j]
            list_2[i][j] = list_1[i][j] + list_1[i-1][j]
        elif j == i:                                               #最右边那一个只能来自左上角。
            list_2[i][j] = list_1[i][j] + list_1[i-1][j-1]
        else:
            list_2[i][j] = list_1[i][j] + max(list_1[i-1][j],list_1[i-1][j-1])

if ((n % 2) == 1):                   #若为奇数,最底层的终点应该是最中间那个,最底层的中间那一个为:list[n][(n%2)+1]
    print(list_2[i][j//2])
if ((n % 2) == 0):                   #若为偶数,最底层的终点为最中间的两个之一,取其中最大的一个就1行了,分别是:list[n][n//2]与list[n][(n//2)+1]
    print(max(list_2[i][n//2-1],list_2[i][n//2]))

5. Score Analysis

insert image description here
insert image description here
answer:

import os
import sys

# 请在此输入您的代码
n=int(input())
lis=list()
for i in range(n):
  lis.append(int(input()))

print(max(lis))
print(min(lis))
print("{:.2f}".format(sum(lis)/n))

The follow-up will continue to update, and strive to record the questions

Guess you like

Origin blog.csdn.net/weixin_61587867/article/details/131823052