denghuolanshan_1004 @ 2023-01-09 18:49:35
a=int(input())
for i in range(a):
x=list(map(int,input().split()))
b=x[0]
c=0
for j in range(1,x[0]+1):
b*=j
b=str(b)
for j in range(0,len(b)):
if b[j]==b[1]:
c+=1
print(c)
by Loser_Syx @ 2023-01-09 18:53:46
@denghuolanshanchu 直接普通乘法运算不行吗,你又不是C++,还要字符串做(换句话说,数位分离会吗)
by Loser_Syx @ 2023-01-09 18:54:45
@denghuolanshanchu 我的AC代码:
n = int(input())
i = 1
while i <= n:#不高兴写for了
a, b = map(int, input().split())
j = 1
sum = 1
while j <= a:
sum *= j
j += 1
cnt = 0
while sum != 0:
if(sum % 10 == b):
cnt += 1
sum = sum // 10
print(cnt)
i += 1
by Terrible @ 2023-01-09 19:09:48
a=int(input())
for i in range(a):
x=list(map(int,input().split()))
b=x[0]
x[1]=str(x[1])#改成str
c=0
for j in range(1,x[0]):#去掉+1
b*=j
b=str(b)
for j in range(0,len(b)):
if b[j]==x[1]:#改成x[1]
c+=1
print(c)
by Terrible @ 2023-01-09 19:11:52
import math
t=int(input())
for _ in range(t):
a,b=map(int,input().split())
print(str(math.factorial(a)).count(str(b)))
话说你不是在用Python吗?
by mazichen @ 2023-01-09 19:35:37
既然Python中有.count()
干嘛不用呢
t = int(input())
for i in range(t):
n,a = map(int,input().split())
res = 1
for j in range(1,n+1):
res *= j
print(str(res).count(str(a)))
验证码6674