Python 编程练习题

Python 编程练习题

写出来的题代码不舍得删,就记录在这里吧。

一、
Python 编程练习题_第1张图片
Python 编程练习题_第2张图片
Python 编程练习题_第3张图片

n = int(input())
i = 3
a = [0]*(n+1) # +1防止越界
a[1] = 3
a[2] = 9
if n<3:
    print(a[n])
else:
    while True:
        if i>n:
            break
        a[i] = (2*(int(a[i-1])+int(a[i-2])))%10000000000 #找规律得此核心代码,提前取余防止超内存
        i += 1
    
    if n<=36:
        print(a[i-1])
    else:
        print("......",end="")
        print('%.10d'%a[i-1]) #保证前导0补足10位

二、回收站选址
Python 编程练习题_第4张图片
Python 编程练习题_第5张图片
Python 编程练习题_第6张图片
Python 编程练习题_第7张图片
Python 编程练习题_第8张图片

n = int(input())
a = [[0 for _ in range(2)] for _ in range(n)]
c = [0]*5 
for count in range (0,n):
    b = input().split() 
    a[count][0] = int(b[0])
    a[count][1] = int(b[1])

for count in range (0,n):
    if ([a[count][0]+1,a[count][1]] in a) and ([a[count][0]-1,a[count][1]] in a) and ([a[count][0],a[count][1]+1] in a) and ([a[count][0],a[count][1]-1] in a):
        socre = 0
        if [a[count][0]+1,a[count][1]+1] in a:
            socre += 1
        if [a[count][0]+1,a[count][1]-1] in a:
            socre += 1
        if [a[count][0]-1,a[count][1]+1] in a:
            socre += 1
        if [a[count][0]-1,a[count][1]-1] in a:
            socre += 1
        for i in range (0,5):
            if i == socre:
                c[i] += 1

for i in range (0,5):
    print(c[i])

你可能感兴趣的:(蓝桥杯Python组)