Submission #36976680


Source Code Expand

MOD = 998244353
H_inv = pow(100, MOD-2, MOD)


def main():
    N, P = map(int, input().split())

    ans = calc_ev(N, P)
    print(ans)


def calc_ev(N, P):
    if P == 0: return N
    if P == 100: return -(-N//2)

    dp = [0]*(N+2)

    for i in range(N):
        dp[i+1] += (dp[i]+1)*(100-P)*H_inv
        dp[i+1] %= MOD

        dp[i+2] += (dp[i]+1)*P*H_inv
        dp[i+2] %= MOD

    return (dp[N-1]+1)%MOD


if __name__ == '__main__': main()

Submission Info

Submission Time
Task E - Critical Hit
User hannaheptapod
Language PyPy3 (7.3.0)
Score 500
Code Size 449 Byte
Status AC
Exec Time 145 ms
Memory 91696 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 39
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt
Case Name Status Exec Time Memory
example_00.txt AC 65 ms 61596 KiB
example_01.txt AC 58 ms 61632 KiB
example_02.txt AC 55 ms 61780 KiB
hand_00.txt AC 55 ms 61780 KiB
hand_01.txt AC 54 ms 61432 KiB
hand_02.txt AC 57 ms 61616 KiB
hand_03.txt AC 52 ms 61532 KiB
hand_04.txt AC 54 ms 61724 KiB
hand_05.txt AC 57 ms 61732 KiB
hand_06.txt AC 57 ms 61600 KiB
hand_07.txt AC 145 ms 91428 KiB
hand_08.txt AC 57 ms 61628 KiB
hand_09.txt AC 130 ms 90284 KiB
hand_10.txt AC 98 ms 81220 KiB
hand_11.txt AC 133 ms 89104 KiB
hand_12.txt AC 54 ms 61536 KiB
hand_13.txt AC 55 ms 61752 KiB
random_00.txt AC 62 ms 70488 KiB
random_01.txt AC 75 ms 74772 KiB
random_02.txt AC 61 ms 68564 KiB
random_03.txt AC 83 ms 77276 KiB
random_04.txt AC 80 ms 77248 KiB
random_05.txt AC 86 ms 77428 KiB
random_06.txt AC 97 ms 80500 KiB
random_07.txt AC 105 ms 83164 KiB
random_08.txt AC 93 ms 80204 KiB
random_09.txt AC 108 ms 83424 KiB
random_10.txt AC 117 ms 86168 KiB
random_11.txt AC 106 ms 83148 KiB
random_12.txt AC 130 ms 88792 KiB
random_13.txt AC 132 ms 88564 KiB
random_14.txt AC 120 ms 86380 KiB
random_15.txt AC 133 ms 91264 KiB
random_16.txt AC 136 ms 91696 KiB
random_17.txt AC 142 ms 91432 KiB
random_18.txt AC 141 ms 91504 KiB
random_19.txt AC 134 ms 91648 KiB
random_20.txt AC 140 ms 91432 KiB
random_21.txt AC 141 ms 91492 KiB