QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#188621#4917. 中奖率hos_lyric#0 3ms10576kbPython32.1kb2023-09-26 05:12:012024-07-04 02:09:28

Judging History

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

  • [2024-07-04 02:09:28]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:10576kb
  • [2023-09-26 05:12:01]
  • 提交

answer

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)

詳細信息

Subtask #1:

score: 0
Dangerous Syscalls

Test #1:

score: 0
Dangerous Syscalls

input:

93594 19
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:


result:


Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 3ms
memory: 10576kb

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
Dangerous Syscalls

Test #26:

score: 0
Dangerous Syscalls

input:

91666 20
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:


result:


Subtask #5:

score: 0
Dangerous Syscalls

Test #36:

score: 0
Dangerous Syscalls

input:

98506 19
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:


result:


Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%