输入在第1行给出不超过105的正整数N,即学生总人数。随后1行给出N名学生的百分制整数成绩,中间以空格分隔。最后1行给出要查询的分
数个数K(不超过N的正整数),随后是K个分数,中间以空格分隔。
在一行中按查询顺序给出得分等于指定分数的学生人数,中间以空格分隔,但行末不得有多余空格。
10 60 75 90 55 75 99 82 90 75 50 3 75 90 88
3 2 0
acetao
import collections
L = input().split()
N = eval(L.pop(0))
D = collections.Counter(L[:N])
L = [str(D[i]) if i in D else '0' for i in L[N + 1:]]
print(' '.join(L))
是不是一直EOFError: while reading the line.
我甚至一度怀疑自己对input的理解
别想自己哪步坑了,题目出问题了!!
换成以下数据:
10 60 75 90 55 75 99 82 90 75 50 3 75 90 88
# -*- coding : utf-8 -*-
from collections import Counter
line = list(input().split())
count = Counter(line[1:1 + int(line[0])])
_, *index = line[1 + int(line[0]):]
result = []
for i in index:
if i not in count.keys():
result.append('0')
else:
result.append(str(count[i]))
print(' '.join(result))
a=list(map(int,input().split()))
n,res=a[0],[]
for i in a[n+2:]:
res.append(str(a[1:n+1].count(i)))
print(" ".join(res))
a,b,c,res=input(),list(map(int,input().split())),list(map(int,input().split())),[]
for i in c[1:]:
res.append(str(b.count(i)))
print(" ".join(res))