結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー flygonflygon
提出日時 2022-11-25 21:56:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,224 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 82,088 KB
実行使用メモリ 77,048 KB
最終ジャッジ日時 2024-04-10 03:08:16
合計ジャッジ時間 9,068 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
62,760 KB
testcase_01 AC 47 ms
62,308 KB
testcase_02 AC 47 ms
63,624 KB
testcase_03 AC 573 ms
76,556 KB
testcase_04 AC 46 ms
62,276 KB
testcase_05 AC 46 ms
63,748 KB
testcase_06 AC 47 ms
63,060 KB
testcase_07 AC 1,224 ms
76,572 KB
testcase_08 AC 336 ms
76,588 KB
testcase_09 AC 1,162 ms
76,900 KB
testcase_10 AC 1,153 ms
76,688 KB
testcase_11 AC 836 ms
76,576 KB
testcase_12 AC 792 ms
76,996 KB
testcase_13 AC 45 ms
62,660 KB
testcase_14 AC 369 ms
76,568 KB
testcase_15 AC 329 ms
77,048 KB
testcase_16 AC 51 ms
66,028 KB
testcase_17 AC 281 ms
76,680 KB
testcase_18 AC 282 ms
76,708 KB
testcase_19 AC 171 ms
76,500 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