QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#504685 | #9107. Zayin and Count | PhantomThreshold# | AC ✓ | 726ms | 10624kb | Python3 | 1.3kb | 2024-08-04 14:47:40 | 2024-08-04 14:47:40 |
Judging History
answer
T=int(input())
for tt in range(T):
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sa=sum(a)
sb=sum(b)
sx=input()
if sx=="0":
cnt=0
else:
cnt=a[0]
for digit in range(1,len(sx)):
cnt+=((sa-1) if a[0] else sa)*sa**(digit-1)
#print("???",cnt)
for i in range(len(sx)):
for j in range(int(sx[i])):
#print("?",i,j)
if i==0 and j==0:
continue
if a[j]:
cnt+=sa**(len(sx)-i-1)
#print("sub",sa**(len(sx)-i-1))
#print("!! ",cnt)
if(cnt==0 and b[0]):
print("0")
continue
elif b[0]:
cnt-=1
lans=0
for digit in range(1,100):
if cnt>=((sb-1) if b[0] else sb)*sb**(digit-1):
cnt-=((sb-1) if b[0] else sb)*sb**(digit-1)
else:
lans=digit
break
#print("len",lans,"cnt",cnt)
ans=""
for i in range(lans):
for j in range(10):
if i==0 and j==0:
continue
if b[j]:
if cnt>=sb**(lans-i-1):
cnt-=sb**(lans-i-1)
else:
ans+=str(j)
break
print(ans)
详细
Test #1:
score: 100
Accepted
time: 726ms
memory: 10624kb
input:
10000 1 0 0 0 1 1 0 0 0 1 0 0 1 0 1 1 1 1 0 0 950595954440050004054505054050 1 0 0 0 1 1 1 1 0 0 1 1 1 0 1 0 0 0 1 1 45467007076660767550460064 1 1 1 1 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 1 23373171320213300170200722 0 0 0 0 1 1 1 0 1 0 0 0 1 0 0 1 0 1 1 1 558565664666565565558468668484 1 1 0 0 1 0 1 0 1 ...
output:
52755244567262766742575722 41990991999414091249949 101364364636933104003903 57558888789255872922852552 757222758857875785288225787822 761161760076076167101117776167 56666586555668686566656586856566686658 15611661611611111511116116661611616155 505885888775005550558080707878 3912911219633669993999199 ...
result:
ok 10000 lines