Test questions and analysis of the 12th Blue Bridge Cup National Championship (python group)
- Question A: Bandwidth
- Question B: Pure Prime Numbers
- Question C: Complete Date
- Question D: Minimum Weight
- Question E: Capitalization
- Question F: 123
- Question G: Iceberg
- Question H: Sum and Product
- Question I: Binary Problem
- 10. Question J: Flip the bracket sequence
Share the test questions first, and then gradually improve the problem solution
The link to the source file of the test question is at the end of the text
My insight : Compared with those old competitions of ACM, winning the Blue Bridge Cup is not difficult (for those brothers who want to win some awards during college), the first time I participated in the algorithm competition, it was an accident won the first provincial one, and then participated in the national competition and won the third national championship. He is also satisfied with his first competition trip.
After all the experience, looking back, it turned out that it was not so difficult to win the award (python group, weak province), most of the questions related to the algorithm were not written in this competition (the algorithm is weak, it is relatively easy to win the Blue Bridge Cup award). ), know my true level, and know that I still have a long way to go in the algorithm part, but through this competition, I have met excellent people, seen new things, and achieved some achievements. The above motivates me In the spare time after class, learn algorithms to hone skills, and continue to invest in the next competition. I hope that the junior can break through himself, and one day can compete with the masters of the college and win glory for the college!
My advice : Don't be afraid of failure, try more, and get in touch with new things, so that you can grow through experience and constantly break through yourself.
Question A: Bandwidth
【analyze】
【Code】
#结果为 25
1Byte=8bit
1MB/s=8Mbps=8Mb/s
200*1024/8=25600KB/s=25MB/s
Question B: Pure Prime Numbers
【analyze】
【Code】
#纯质数
from math import *
#判断是否为质数
def isPrime(n):
m=int(sqrt(n))+1
for i in range(2,m):
if n%i==0:
return False
return True
#判断每一位是否都为质数
def eve(n):
res=['2','3','5','7']
s=str(n)
if s.count(res[0])+s.count(res[1])+s.count(res[2])+s.count(res[3])==len(s):
return 1
return 0
ans=0
for i in range(20210606):
if (isPrime(i) and eve(i)):
ans+=1
print(ans)
Question C: Complete Date
【analyze】
【Code】
from datetime import *
from math import *
a=date(2001,1,1)
b=date(2021,12,31)
gap=timedelta(days=1)
#求每个数位的和
def cul(n):
summ=0
nn=str(n)
for i in nn:
summ+=int(i)
return summ
#判断是否为完全平方数
def judge(mm):
x=sqrt(mm)
y=int(sqrt(mm))
if x==y:
return 1
return 0
ans=0
while a!=b:
a=a+gap
year=a.year
month=a.month
day=a.day
#和
summm=cul(year)+cul(month)+cul(day)
#print(a)
#print(summm)
if judge(summm):
ans+=1
print(a)
print(ans)
Question D: Minimum Weight
【analyze】
【Code】
Question E: Capitalization
【analyze】
【Code】
Question F: 123
【analyze】
【Code】
Question G: Iceberg
【analyze】
【Code】
Question H: Sum and Product
【analyze】
【Code】
#样例不能完全通过
n=int(input())
res=list(map(int,input().split()))
ans=0
def judge(n):
summ=sum(n)
cul=1
for i in ress:
cul*=i
if summ==cul:
return 1
return 0
for i in range(n):
for j in range(i,n+1):
ress=res[i:j]
if len(ress)>0:
if judge(ress):
ans+=1
j+=1
i+=1
print(ans)
Question I: Binary Problem
【analyze】
【Code】
#样例不能完全通过
N,K=map(int,input().split())
ans=0
for i in range(1,N+1):
s=bin(i)[2:]
if s.count("1")==K:
ans+=1
print(ans)
Question J: Flip the bracket sequence
【analyze】
【Code】
Link: https://pan.baidu.com/s/1KoCDQ34GBkf_l3y6t768ww
Extraction code: 7e0n