QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#188626#4917. 中奖率hos_lyric#14 1350ms19804kbPython32.2kb2023-09-26 05:26:272024-07-04 02:46:25

Judging History

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

  • [2024-07-04 02:46:25]
  • 评测
  • 测评结果:14
  • 用时:1350ms
  • 内存:19804kb
  • [2023-09-26 05:26:27]
  • 提交

answer

import sys
sys.set_int_max_str_digits(10**5)

N, T = map(int, input().split())
S = input()

Y = [0 for i in range(N + 1)]
for i in range(N):
    Y[i + 1] = Y[i] + (ord(S[i]) - ord('0'))
# print(Y)
D = [0 for i in range(N)]
for i in range(N):
    D[i] = N * Y[i] - Y[N] * i
# print(D)

for T in range(T):
    O, K = map(int, input().split())
    if (O == 1):
        # sub1
        print(K * N)
    else:
        Q = K // N
        R = K % N
        if (D[R] < 0):
            print("inf")
        elif (D[R] == 0):
            hasBig = False
            for r in range(N):
                if (D[r] > 0):
                    hasBig = True
            if (hasBig):
                print("inf")
            else:
                ans = 0
                cnt = 0
                for r in range(N):
                    if (D[r] == 0):
                        cnt += 1
                        if (r <= R):
                            ans += 1
                        if (r == 0):
                            ans -= 1
                ans += cnt * Q
                print(ans)
        else:
            a = K // D[R]
            b = K % D[R]
            c = (Y[N] * Q + Y[R]) // D[R]
            d = (Y[N] * Q + Y[R]) % D[R]
            ans = 0
            cntA = 0
            cntC = 0
            for r in range(N):
                if (D[r] > 0):
                    # Y[r]/r >= Y[K]/K ?
                    if (Q >= ((Y[R] * r - R * Y[r]) + D[R] - 1) // D[R]):
                        # q <= (a D[R] + b) Y[r] - (c D[R] + d) r
                        cntA += Y[r]
                        cntC -= r
                        e = b * Y[r] - d * r
                        f = e // D[R]
                        ans += (f + 1)
                        if (r == 0):
                            ans -= 1
                        if (e % D[R] == 0):
                            # (a * Y[r] - c * r + f, r) > (Q, R)
                            q = a * Y[r] - c * r + f
                            if (q > Q or (q == Q and r > R)):
                                ans -= 1
            ans += cntA * a
            ans += cntC * c
            print(ans)

详细

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 74ms
memory: 16436kb

input:

93594 19
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

803592238894397000180010742478410576139869323112765266001511168406933953751236048305575854734087992434865734898666775073462056595681265138821122297618629090129568166018988058397842512784043408247048475083486672197520209680936205310495190027161434933868319162317581353076485586012510746832534790123318...

result:

ok 19 tokens

Test #2:

score: 0
Accepted
time: 55ms
memory: 16276kb

input:

91106 19
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

inf
inf
inf
inf
13250042107896464722639737551541466942179901318817839832766590049487752727865912250795382770204236165270082111796839055561744227636073331650212700910581348097835459150251688363718468552900251250148301582337176568548165076825749090832639499887382431511630515262690992013373658775659429...

result:

ok 19 tokens

Test #3:

score: 0
Accepted
time: 65ms
memory: 16256kb

input:

91004 19
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

615583033926412665379213953324038024217834471026294801388188380855415202841104551684169952830165295737948000277599376689161324741020690179665753283567317214074727589342722310194779455556310818004374376474764064937590258429980614187691752943635481928305924995147441001944209678975366299644962193997878...

result:

ok 19 tokens

Test #4:

score: 0
Accepted
time: 82ms
memory: 16324kb

input:

90255 20
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

499599650596627581409270516073361171534798169651401128905539595097904284149229507117902151246635636602106763929398082171217870421053986702009355855535129786260850675383419648681127018158100775558533952949402381637753162134550874268417162202985795686214400585039764184003031446966858170110874690477358...

result:

ok 20 tokens

Test #5:

score: 0
Accepted
time: 58ms
memory: 16400kb

input:

91120 20
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

inf
79720591846983829206255887296207669486915366790122276434980101585360431827746713261002508648352372575865363390100523993630288523905911853973318127707889991724762296859274660492425147944952897963807830595800561901914978699828863421552748209566274991181115114248717641246059782816631387147071628022...

result:

ok 20 tokens

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 16ms
memory: 10520kb

input:

10 19
0000000000
2 241
1 405
1 927
1 669
1 734
1 349
2 493
1 828
1 385
1 855
2 761
1 63
1 288
1 754
2 91
1 863
2 805
2 1000
1 1000

output:

241
4050
9270
6690
7340
3490
493
8280
3850
8550
761
630
2880
7540
91
8630
805
1000
10000

result:

wrong answer 2nd words differ - expected: '405', found: '4050'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 13
Accepted

Test #26:

score: 13
Accepted
time: 379ms
memory: 13448kb

input:

91666 20
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

515706124162066910404299759270263525075572767596736003465355923316260588149010617187359188941516324390245173109156994742981144311903350592651694874773059936377465166504183446390352558958540404515986128670780159685531688747924073414308447680356209302719213735419339034163216206854876449919662582900737...

result:

ok 20 tokens

Test #27:

score: 0
Accepted
time: 381ms
memory: 16492kb

input:

91047 20
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

748490273573792980373170496345932289792264023510501461386640731746530837775985011360693655655538352612548991850863544262166372647195373109391450350236987371183192812616376657263677465623740226504269832462386067930101999093116909436323318899728117997747067096632539706580241112266144163828519249301668...

result:

ok 20 tokens

Test #28:

score: 0
Accepted
time: 209ms
memory: 19220kb

input:

92486 19
110100000000000000110000000000100000000000000011000001001000010000010000000000100100001000000001101000000001011100000100010000000000000010000010001001000000000000000000000010000010001101000000001010010010000001000000110001100110000100101100001001100100100000000000010000000000000001010110000...

output:

inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
65986075054599739720012701630831185271110376577710956354155795249031175809009390746092705206288087294293403254292953327740384132264386725134793857054678394086844847065095541776644414503257258213388206060729019472813862535764008464101493529685679752732762570081...

result:

ok 19 tokens

Test #29:

score: 0
Accepted
time: 307ms
memory: 19068kb

input:

90758 19
111001110101010111100000111111011011001010101101110101111111101000011100011111111010111111010110011111001010111111101110101110010110110111000011110110111001100100001010011001010001110111011110111111111101110110111001101110101100111010010111100011000101101110011011111101110111100011110111111...

output:

337152640595339377254913355446254892275950588290486782075348462146043348153437383075163218482882384949983968092847114987978727985457664584745249748842150893129020441591183196333370705055984869426758646982814357613345456867523827515149962034146732136117858448360902802565799798832441703259791269764809...

result:

ok 19 tokens

Test #30:

score: 0
Accepted
time: 65ms
memory: 19296kb

input:

95944 20
010111110111111111001111111111101111111011111011011101101110111111111101101111111111111111111111111111101011011110111111111111111111111111111110111101111111110111101110011111111111111111111101101101101111111111110110111111101111111101101111111101111111111111111111101111111111110100011101111...

output:

inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf

result:

ok 20 tokens

Test #31:

score: 0
Accepted
time: 1350ms
memory: 19352kb

input:

92585 20
110011011000101000000101010010100000000100000001110010010001100110001000100000100100000000111110001000000001000001100000110001001010000000101100000010100100001011010000001100000011000100011001000100000010010100001101000001110100001000011100010110100000100000101000010000000101000000100010010...

output:

693151164353298294991771915092246165588784011427723401514863569537180974110856679276502848848450095232556023520581621103706505329485541531644093395334224709813099430572342689943389061768308122334167396889122558885489842353859845505679740760989001467096316722773918455965593584892515339969002792035902...

result:

ok 20 tokens

Test #32:

score: 0
Accepted
time: 1213ms
memory: 19804kb

input:

100000 19
11010101011011001011010111100000010010101100101010111000101110101001010110011011010011100100011110010011010011110111000100110000001111110010101000011111010011011101001100000000101011110100100100101100101010101100110111010011000101110111010110101000010110001010111110001010110100110000001111...

output:

171664461199134562766995650684440673085489422465326109270356812483138547934706911599756894207664574188038519627617045518815980608296136814038903827336872029429200125283024307872759381900102481215772231730929597377309317705827303189555946879704202361491952110134028530508207284059394040436511100411837...

result:

ok 19 tokens

Test #33:

score: 0
Accepted
time: 201ms
memory: 19088kb

input:

90139 20
101101100100111111111011100111110110111001111101101101110111011101011100111110111010110111101110110111101011011101100111110111011011101101110111101011011101101110101111101011101100111110101111011101101110110101111001111101101110110011111011101110110110111001101111101110011111011011101101110...

output:

114295361082305127942208281911086652195193612036965258194540554839765604416562780276165239338044991656166078586296137971810820270121979910956362520343058615413830387682572956846149751679906531190159869196033901257029539803703475752647797700268137583373220831250186514085304302366054423749897416545653...

result:

ok 20 tokens

Test #34:

score: 0
Accepted
time: 53ms
memory: 19600kb

input:

98059 19
101111111111111111011011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111011111111111111111...

output:

inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf
inf

result:

ok 19 tokens

Test #35:

score: 0
Accepted
time: 200ms
memory: 18980kb

input:

90139 20
101101100100111111111011100111110110111001111101101101110111011101011100111110111010110111101110110111101011011101100111110111011011101101110111101011011101101110101111101011101100111110101111011101101110110101111001111101101110110011111011101110110110111001101111101110011111011011101101110...

output:

114295361082305127942208281911086652195193612036965258194540554839765604416562780276165239338044991656166078586296137971810820270121979910956362520343058615413830387682572956846149751679906531190159869196033901257029539803703475752647797700268137583373220831250186514085304302366054423749897416545653...

result:

ok 20 tokens

Subtask #5:

score: 0
Wrong Answer

Test #36:

score: 0
Wrong Answer
time: 811ms
memory: 16708kb

input:

98506 19
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

797421679025153052547802701391212570210379630500790526920814874597984692004732251884471064856660869762141384942984614490845295972217433732401878859170633409779037020398402107019096645895597248820899182789527954116767104110201617414191150208309934751946525321779137242946155293684393891543880992992703...

result:

wrong answer 1st words differ - expected: '129925218195110981928395603118...4444988083658465926564772872533', found: '797421679025153052547802701391...2570384278343139056017981769288'

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%