202206-1 归一化处理
解答:
import math
n = int(input())
list_a = list(map(int,input().split()))
a_hat = sum(list_a)/n
D_a_sq = math.sqrt(sum([(i - a_hat)**2 for i in list_a])/n)
for i in list_a:
i = (i - a_hat)/D_a_sq
print(i)
202206-2 寻宝!大冒险!
70分:
n,L,S = map(int,input().split())
money_point = []
for i in range(n):
x_y = list(map(int,input().split()))
money_point.append(x_y)
money_map = []
for s1 in range(S+1):
s2 = list(map(int,input().split()))
money_map.insert(0,s2)
num = 0
for x_y_list in money_point:
flag = 1
for s1 in range(S+1):
for s2 in range(S+1):
x = s1 + x_y_list[0]
y = s2 + x_y_list[1]
if x > L or y > L:
flag = 0
break
if money_map[s1][s2] == 1 and [x,y] not in money_point:
flag = 0
break
elif money_map[s1][s2] == 0 and [x,y] in money_point:
flag = 0
break
if flag == 0:
break
if flag == 1:
num += 1
print(num)