結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー flygonflygon
提出日時 2022-11-25 21:56:01
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,339 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 78,320 KB
最終ジャッジ日時 2023-07-25 10:02:59
合計ジャッジ時間 11,077 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
76,700 KB
testcase_01 AC 102 ms
77,220 KB
testcase_02 AC 103 ms
76,960 KB
testcase_03 AC 652 ms
78,320 KB
testcase_04 AC 103 ms
76,728 KB
testcase_05 AC 104 ms
76,728 KB
testcase_06 AC 104 ms
76,668 KB
testcase_07 AC 1,331 ms
78,204 KB
testcase_08 AC 418 ms
78,228 KB
testcase_09 AC 1,326 ms
78,264 KB
testcase_10 AC 1,339 ms
78,124 KB
testcase_11 AC 953 ms
78,252 KB
testcase_12 AC 902 ms
78,116 KB
testcase_13 AC 104 ms
76,728 KB
testcase_14 AC 457 ms
78,092 KB
testcase_15 AC 394 ms
78,252 KB
testcase_16 AC 110 ms
77,172 KB
testcase_17 AC 364 ms
78,184 KB
testcase_18 AC 362 ms
78,164 KB
testcase_19 AC 232 ms
78,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd
mod = 998244353

n = int(input())

#nCk
def com(n,mod):
  fact = [1,1]
  factinv = [1,1]
  inv = [0,1]
  for i in range(2,n+1):
    fact.append((fact[-1]*i)%mod)
    inv.append((-inv[mod%i]*(mod//i))%mod)
    factinv.append((factinv[-1]*inv[-1])%mod)
  return fact, factinv

f,fi = com(5000, mod)
def ncr(n,r):
  return f[n] * fi[r] * fi[n-r] % mod
ans = 0

for k in range(1,n):
  if 3 * k > n: break
  for i in range(3*k-1,n):
    tmp = ncr(i,3*k-1) * pow(25, i-3*k+1,mod) * pow(26, n-i-1,mod)
    ans += tmp
    ans %= mod

print(ans)
0