Submission #14562582


Source Code Expand

Copy
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7

def main(K, N, MOD):
    def fact_table(N, MOD):
        inv = np.empty(N, np.int64)
        inv[0] = 0
        inv[1] = 1
        for n in range(2, N):
            q, r = divmod(MOD, n)
            inv[n] = inv[r] * (-q) % MOD
        fact = np.empty(N, np.int64)
        fact[0] = 1
        for n in range(1, N):
            fact[n] = n * fact[n - 1] % MOD
        fact_inv = np.empty(N, np.int64)
        fact_inv[0] = 1
        for n in range(1, N):
            fact_inv[n] = fact_inv[n - 1] * inv[n] % MOD
        return fact, fact_inv, inv

    fact, fact_inv, inv = fact_table(2_000_010, MOD)
    f = np.zeros(K + 1, np.int64)
    f = fact[N - 1:K + N] * fact_inv[N - 1] % MOD * fact_inv[0:K + 1] % MOD
    x = 1
    for i in range(1, K + 1):
        x = (x * 25) % MOD
        f[i] = f[i] * x % MOD
    for i in range(1, K + 1):
        f[i] += f[i - 1] * 26
        f[i] %= MOD
    return f[-1]

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    signature = (i8, i8, i8)

    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()

from my_module import main

K = int(readline())
N = len(read().rstrip())

print(main(K, N, MOD))

Submission Info

Submission Time
Task F - Strivore
User maspy
Language Python (3.8.2)
Score 600
Code Size 1441 Byte
Status
Exec Time 344 ms
Memory 73288 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt
Subtask1 600 / 600 sample_01.txt, sample_02.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt
Case Name Status Exec Time Memory
sample_01.txt 278 ms 72540 KB
sample_02.txt 276 ms 72928 KB
sub1_01.txt 333 ms 72972 KB
sub1_02.txt 344 ms 72884 KB
sub1_03.txt 330 ms 72556 KB
sub1_04.txt 342 ms 72992 KB
sub1_05.txt 269 ms 73008 KB
sub1_06.txt 277 ms 72788 KB
sub1_07.txt 271 ms 72860 KB
sub1_08.txt 279 ms 72580 KB
sub1_09.txt 273 ms 73288 KB
sub1_10.txt 280 ms 73100 KB
sub1_11.txt 312 ms 72956 KB
sub1_12.txt 300 ms 72516 KB
sub1_13.txt 332 ms 72932 KB
sub1_14.txt 292 ms 73184 KB
sub1_15.txt 277 ms 72908 KB
sub1_16.txt 276 ms 72988 KB
sub1_17.txt 269 ms 72976 KB
sub1_18.txt 268 ms 72844 KB
sub1_19.txt 277 ms 72980 KB
sub1_20.txt 313 ms 72988 KB
sub1_21.txt 299 ms 73104 KB
sub1_22.txt 317 ms 73100 KB
sub1_23.txt 290 ms 73064 KB
sub1_24.txt 325 ms 73288 KB
sub1_25.txt 315 ms 72952 KB
sub1_26.txt 286 ms 72552 KB
sub1_27.txt 294 ms 73008 KB
sub1_28.txt 296 ms 72960 KB