题目链接:https://www.lanqiao.cn/problems/205/learning/
思路:
1.把分步输入的数据放在一个列表里
2.分别遍历操作求缺项m和重复项n
代码:
import collections
from collections import Counter
res=collections.deque()
temp=collections.deque()
n=int(input())
for i in range(n):
li=list(map(int,input().split())) #输入格式
res.append(li)
for i in res:
for j in i:
temp.append(j) #把数据放在一个队列里
temp=sorted(temp)
for i in range(temp[0],temp[-1]+1): #遍历求m
if i not in temp:
m=i
cot=list(Counter(temp).items())
for i in cot: #遍历求n
if i[1]==2:
n=i[0]
print(m,' ',n)
总结:此题考查了collections库的工具灵活使用,算法并不难