QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#504685#9107. Zayin and CountPhantomThreshold#AC ✓726ms10624kbPython31.3kb2024-08-04 14:47:402024-08-04 14:47:40

Judging History

你现在查看的是最新测评结果

  • [2024-08-04 14:47:40]
  • 评测
  • 测评结果:AC
  • 用时:726ms
  • 内存:10624kb
  • [2024-08-04 14:47:40]
  • 提交

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)

Details

Tip: Click on the bar to expand more detailed information

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