結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
68,040 KB
testcase_01 AC 67 ms
68,040 KB
testcase_02 AC 65 ms
68,040 KB
testcase_03 AC 64 ms
68,040 KB
testcase_04 AC 65 ms
68,040 KB
testcase_05 AC 69 ms
68,040 KB
testcase_06 AC 64 ms
68,040 KB
testcase_07 AC 64 ms
68,040 KB
testcase_08 AC 64 ms
68,040 KB
testcase_09 AC 65 ms
68,040 KB
testcase_10 AC 64 ms
68,040 KB
testcase_11 AC 64 ms
68,040 KB
testcase_12 AC 79 ms
73,096 KB
testcase_13 AC 91 ms
77,028 KB
testcase_14 AC 94 ms
77,108 KB
testcase_15 AC 96 ms
77,216 KB
testcase_16 AC 65 ms
68,040 KB
testcase_17 AC 82 ms
73,852 KB
testcase_18 AC 91 ms
77,044 KB
testcase_19 AC 77 ms
72,480 KB
testcase_20 AC 79 ms
72,772 KB
testcase_21 AC 64 ms
68,040 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 ii in range(3):
    for i in range(n):
        leng = n - 1 + 2 * i + n - i - ii + 3 * ii
        tmp = 10 * i + n - i - ii + 100 * ii
        if tmp > leng:
            break
        rem = leng - tmp
        dp = [[0] * (rem + 1) for _ in range(n+1-i-ii)]
        dp[0][0] = 1
        for j in range(1,n+1-i-ii):
            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 + ii != 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+ii+rem-j-1,i+ii-1) % mod * ncr(n,i) % mod * ncr(n-i,ii) % mod
                    ans %= mod
        else:
            ans += dp[-1][-1]

print(ans)
0