前言
7
缺:201409-1 到 201909-1
202009-1称检测点查询
def cal_dis(x1,y1,x2,y2):
return ((x2-x1)**2 + (y2-y1)**2)**(1/2)
n,X,Y = list(map(int, input().split()))
dis_lst = []
for i in range(n):
x,y = list(map(int, input().split()))
dis_lst.append((i+1, cal_dis(x,y,X,Y)))
dis_lst = sorted(dis_lst, key=lambda x:(x[1],x[0]))
print(dis_lst[0][0])
print(dis_lst[1][0])
print(dis_lst[2][0], end="")
202006-1线性分类器
def check(dot_lst, a1,a2,a3):
res_lst = []
for dot in dot_lst:
res = 1 if a1 + a2*dot[0] + a3*dot[1] >0 else -1
res_lst.append(res)
return sum(res_lst)
n, m = list(map(int, input().split()))
A_lst = []
B_lst = []
for i in range(n):
x,y,type = input().split()
if type == "A":
A_lst.append([int(x),int(y)])
else:
B_lst.append([int(x),int(y)])
for i in range(m):
a1,a2,a3 = list(map(int, input().split()))
check_A = check(A_lst, a1,a2,a3)
check_B = check(B_lst, a1,a2,a3)
if len(A_lst) == abs(check_A) and len(B_lst) == abs(check_B) and check_A * check_B < 0:
print("Yes",end="")
else:
print("No",end="")
# "\n"
if i != m-1:
print()
201912-1报数
num = 0
cot = 1
n = int(input())
ans = [0,0,0,0] # idx=0 for 丁
while cot <= n:
num += 1
if num % 7 == 0 or '7' in str(num):
person_num = num % 4
ans[person_num] += 1
else:
cot += 1
print(ans[1])
print(ans[2])
print(ans[3])
print(ans[0],end="")
201909-1小明种苹果
N,M = list(map(int, input().split()))
tree_lst = []
all_left = 0 # T
for tree_idx in range(1,N+1):
tree_info = list(map(int, input().split()))
tree_have = tree_info[0]
tree_cut = -sum(tree_info[1:])
all_left += tree_have-tree_cut
tree_lst.append([tree_idx, tree_cut])
tree_lst = sorted(tree_lst, key = lambda x:(-x[1], x[0]))
print(all_left,end=" ")
print(tree_lst[0][0],end=" ")
print(tree_lst[0][1], end="")
.
.
.
.
201409-1相邻数对
n = int(input())
num_lst = list(map(int, input().split()))
cot = 0
for idx,num in enumerate(num_lst):
if num - 1 in num_lst[:idx]:
cot += 1
if num + 1 in num_lst[:idx]:
cot += 1
print(cot)
201403-1相反数
restore_lst = []
N = int(input())
cot = 0
for num in map(int, input().split()):
if -num not in restore_lst:
restore_lst.append(num)
else:
cot += 1
restore_lst.remove(-num)
print(cot)
201312-1出现次数最多的数
n = int(input())
num_lst = map(int, input().split())
freq_dict = {}
for num in num_lst:
if num not in freq_dict:
freq_dict[num] = 1
else:
freq_dict[num] += 1
ans_lst = sorted(freq_dict.items(), key=lambda x:x[0])
max_freq = 0
min_num = None
for freq_ in ans_lst:
freq = freq_[1]
if freq > max_freq:
max_freq = freq
min_num = freq_[0]
print(min_num)