結果

問題 No.1964 sum = length
ユーザー siganaisiganai
提出日時 2022-06-03 21:48:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,596 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 78,544 KB
最終ジャッジ日時 2023-10-21 01:47:25
合計ジャッジ時間 5,594 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
68,036 KB
testcase_01 AC 61 ms
68,036 KB
testcase_02 AC 65 ms
68,036 KB
testcase_03 AC 63 ms
68,036 KB
testcase_04 AC 62 ms
68,036 KB
testcase_05 AC 63 ms
68,036 KB
testcase_06 AC 62 ms
68,036 KB
testcase_07 AC 63 ms
68,036 KB
testcase_08 AC 62 ms
68,036 KB
testcase_09 AC 62 ms
68,036 KB
testcase_10 AC 61 ms
68,036 KB
testcase_11 AC 63 ms
68,036 KB
testcase_12 AC 76 ms
72,996 KB
testcase_13 AC 83 ms
77,096 KB
testcase_14 AC 87 ms
77,104 KB
testcase_15 AC 89 ms
77,236 KB
testcase_16 AC 60 ms
68,036 KB
testcase_17 AC 76 ms
73,740 KB
testcase_18 AC 86 ms
77,044 KB
testcase_19 AC 71 ms
72,476 KB
testcase_20 AC 72 ms
72,668 KB
testcase_21 AC 60 ms
68,036 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env PyPy3

from collections import Counter, defaultdict, deque
import itertools
import re
import math
from functools import reduce
import operator
import bisect
from heapq import *
import functools
mod=998244353

import sys
input=sys.stdin.readline

#nCrをmodで割ったあまりを求める
def ncr(n, r):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[r] % mod * g2[n-r] % mod
def npr(n, r):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[n-r] % mod
N = 10 ** 4
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 )
n = int(input())
ans = 0
for i in range(n):
    leng = n - 1 + 2 * i + n - i
    tmp = 10 * i + n - i
    if tmp > leng:
        break
    rem = leng - tmp
    dp = [[0] * (rem + 1) for _ in range(n+1-i)]
    dp[0][0] = 1
    for j in range(1,n+1-i):
        cumsum = [0]
        tmp = 0
        for k in range(rem+1):
            tmp += dp[j-1][k]
            tmp %= mod
            cumsum.append(tmp)
        for k in range(rem+1):
            dp[j][k] = cumsum[k+1] - cumsum[max(0,k-8)]
            dp[j][k] %= mod
    #print(dp)
    if i != 0:
        for j in range(rem+1):
            #print(dp[-1][j] , ncr(i+rem-j-1,i-1) % mod , ncr(n,i) % mod)
            ans += dp[-1][j] * ncr(i+rem-j-1,i-1) % mod * ncr(n,i) % mod
            ans %= mod
    else:
        ans += dp[-1][-1]
print(ans)
0