結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー syunsukesyunsuke
提出日時 2022-11-26 23:16:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,103 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 82,344 KB
実行使用メモリ 76,576 KB
最終ジャッジ日時 2024-04-14 08:55:11
合計ジャッジ時間 8,742 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
61,112 KB
testcase_01 AC 46 ms
61,436 KB
testcase_02 AC 45 ms
61,244 KB
testcase_03 AC 512 ms
76,396 KB
testcase_04 AC 45 ms
62,172 KB
testcase_05 AC 44 ms
61,276 KB
testcase_06 AC 46 ms
61,292 KB
testcase_07 AC 1,062 ms
76,320 KB
testcase_08 AC 300 ms
76,364 KB
testcase_09 AC 1,067 ms
76,240 KB
testcase_10 AC 1,103 ms
76,404 KB
testcase_11 AC 754 ms
76,380 KB
testcase_12 AC 711 ms
76,388 KB
testcase_13 AC 46 ms
61,976 KB
testcase_14 AC 342 ms
76,364 KB
testcase_15 AC 289 ms
76,408 KB
testcase_16 AC 55 ms
65,496 KB
testcase_17 AC 263 ms
76,576 KB
testcase_18 AC 268 ms
76,272 KB
testcase_19 AC 163 ms
75,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ans = 0
mod = 998244353

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 #出力の制限
N = 10000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1,n):
    if n >= i * 3:
        for j in range(3*i,n+1):
            C = cmb(j-1,3*i-1,mod)
            ans += C * pow(25,j-1-(3*i-1),mod) * pow(26,n-(j),mod)
print(ans%mod)
0