denghuolanshan_1004 @ 2022-12-22 16:22:38
a,b=map(int,input().split())
a=str(a)
list1=list(a)
total=0
for ele in range(1,len(list1)):
if a[ele]=="3":
total=total+1
if total==b:
print("YES")
else:
print("NO")
by Eleveslaine @ 2022-12-22 17:14:30
@denghuolanshanchu
a
不用转换成列表,直接字符串是可以的
数组下标从 0
开始。
AC 代码:
a,b=map(int,input().split())
a=str(a)
total=0
for ele in range(len(a)):
if a[ele]=="3":
total+=1 #即total=total+1
if total==b:
print("YES")
else:
print("NO")