QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#188625#4917. 中奖率hos_lyric#1 794ms16720kbPython32.1kb2023-09-26 05:23:072024-07-04 02:09:31

Judging History

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

  • [2024-07-04 02:09:31]
  • 评测
  • 测评结果:1
  • 用时:794ms
  • 内存:16720kb
  • [2023-09-26 05:23:07]
  • 提交

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
                        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)

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 71ms
memory: 16452kb

input:

93594 19
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

803592238894397000180010742478410576139869323112765266001511168406933953751236048305575854734087992434865734898666775073462056595681265138821122297618629090129568166018988058397842512784043408247048475083486672197520209680936205310495190027161434933868319162317581353076485586012510746832534790123318...

result:

ok 19 tokens

Test #2:

score: 0
Accepted
time: 70ms
memory: 16272kb

input:

91106 19
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

inf
inf
inf
inf
13250042107896464722639737551541466942179901318817839832766590049487752727865912250795382770204236165270082111796839055561744227636073331650212700910581348097835459150251688363718468552900251250148301582337176568548165076825749090832639499887382431511630515262690992013373658775659429...

result:

ok 19 tokens

Test #3:

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

input:

91004 19
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

615583033926412665379213953324038024217834471026294801388188380855415202841104551684169952830165295737948000277599376689161324741020690179665753283567317214074727589342722310194779455556310818004374376474764064937590258429980614187691752943635481928305924995147441001944209678975366299644962193997878...

result:

ok 19 tokens

Test #4:

score: 0
Accepted
time: 86ms
memory: 16096kb

input:

90255 20
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

499599650596627581409270516073361171534798169651401128905539595097904284149229507117902151246635636602106763929398082171217870421053986702009355855535129786260850675383419648681127018158100775558533952949402381637753162134550874268417162202985795686214400585039764184003031446966858170110874690477358...

result:

ok 20 tokens

Test #5:

score: 0
Accepted
time: 67ms
memory: 16228kb

input:

91120 20
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

inf
79720591846983829206255887296207669486915366790122276434980101585360431827746713261002508648352372575865363390100523993630288523905911853973318127707889991724762296859274660492425147944952897963807830595800561901914978699828863421552748209566274991181115114248717641246059782816631387147071628022...

result:

ok 20 tokens

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 12ms
memory: 10608kb

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:

231
4050
9270
6690
7340
3490
483
8280
3850
8550
751
630
2880
7540
81
8630
795
990
10000

result:

wrong answer 1st words differ - expected: '241', found: '231'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #26:

score: 0
Wrong Answer
time: 396ms
memory: 13664kb

input:

91666 20
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

515706124162066910404299759270263525075572767596736003465355923316260588149010617187359188941516324390245173109156994742981144311903350592651694874773059936377465166504183446390352558958540404515986128670780159685531688747924073414308447680356209302719213735419339034163216206854876449919662582900737...

result:

wrong answer 1st words differ - expected: '515706124162066910404299759270...8259554310593355679821253912350', found: '515706124162066910404299759270...8259554310593355679821253820684'

Subtask #5:

score: 0
Wrong Answer

Test #36:

score: 0
Wrong Answer
time: 794ms
memory: 16720kb

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%