Python求助

B2068 统计满足条件的 4 位数

Assissian @ 2023-03-12 01:04:36

n = int(input())

numbers = list(map(int, input().split()))

convey=[]

for i in numbers:

s=str(i)[::-1]
list1=[]
for j in s:
    list1.append(int(j))
    count=list1[0]-list1[1]-list1[2]-list1[3]
if count>0:
    convey.append(s)

print(len(convey))


by Lantern_LZY @ 2023-03-12 08:00:31

n=int(input())
c=list(map(int,input().split()))
onedigit=[]
tensplace=[]
hundred=[]
kilobit=[]
num=0
ans=0
for i in range(n):
    onedigit.append(c[i]%10)
    tensplace.append((c[i]%100)//10)
    hundred.append((c[i]%1000)//100)
    kilobit.append((c[i]//1000))
for j in range(n):
    ans=onedigit[j]-tensplace[j]-hundred[j]-kilobit[j]
    if ans>0:
        num+=1
print(num

|