結果
問題 | No.2060 AND Sequence |
ユーザー | ああいい |
提出日時 | 2022-08-28 15:14:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 1,093 bytes |
コンパイル時間 | 207 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 53,120 KB |
最終ジャッジ日時 | 2024-10-15 13:47:14 |
合計ジャッジ時間 | 3,535 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
52,224 KB |
testcase_01 | AC | 43 ms
52,736 KB |
testcase_02 | AC | 43 ms
52,480 KB |
testcase_03 | AC | 43 ms
52,608 KB |
testcase_04 | AC | 43 ms
52,480 KB |
testcase_05 | AC | 43 ms
52,352 KB |
testcase_06 | AC | 43 ms
52,480 KB |
testcase_07 | AC | 43 ms
52,736 KB |
testcase_08 | AC | 43 ms
52,224 KB |
testcase_09 | AC | 43 ms
52,480 KB |
testcase_10 | AC | 43 ms
52,352 KB |
testcase_11 | AC | 44 ms
52,608 KB |
testcase_12 | AC | 43 ms
52,608 KB |
testcase_13 | AC | 43 ms
52,736 KB |
testcase_14 | AC | 44 ms
52,224 KB |
testcase_15 | AC | 43 ms
52,352 KB |
testcase_16 | AC | 43 ms
52,224 KB |
testcase_17 | AC | 43 ms
52,608 KB |
testcase_18 | AC | 43 ms
52,480 KB |
testcase_19 | AC | 43 ms
52,224 KB |
testcase_20 | AC | 43 ms
52,608 KB |
testcase_21 | AC | 43 ms
52,864 KB |
testcase_22 | AC | 43 ms
52,608 KB |
testcase_23 | AC | 43 ms
52,480 KB |
testcase_24 | AC | 43 ms
52,224 KB |
testcase_25 | AC | 43 ms
52,480 KB |
testcase_26 | AC | 43 ms
52,480 KB |
testcase_27 | AC | 43 ms
52,224 KB |
testcase_28 | AC | 44 ms
52,480 KB |
testcase_29 | AC | 43 ms
52,480 KB |
testcase_30 | AC | 44 ms
52,736 KB |
testcase_31 | AC | 44 ms
52,352 KB |
testcase_32 | AC | 43 ms
52,736 KB |
testcase_33 | AC | 43 ms
52,224 KB |
testcase_34 | AC | 44 ms
52,480 KB |
testcase_35 | AC | 43 ms
52,480 KB |
testcase_36 | AC | 43 ms
52,608 KB |
testcase_37 | AC | 43 ms
52,736 KB |
testcase_38 | AC | 43 ms
52,224 KB |
testcase_39 | AC | 44 ms
52,992 KB |
testcase_40 | AC | 44 ms
52,352 KB |
testcase_41 | AC | 43 ms
52,736 KB |
testcase_42 | AC | 43 ms
52,352 KB |
testcase_43 | AC | 43 ms
52,480 KB |
testcase_44 | AC | 43 ms
53,120 KB |
testcase_45 | AC | 43 ms
52,224 KB |
ソースコード
N,M = map(int,input().split()) P = 998244353 C = 50 fact = [1] * C fact_inv = [1] * C for i in range(2,C): fact[i] = fact[i-1] * i % P fact_inv[-1] = pow(fact[-1],P-2,P) for i in range(C-2,1,-1): fact_inv[i] = fact_inv[i + 1] * (i + 1) % P K = 31 dp = [0] * K same = 0 now = 0 for i in range(29,-1,-1): nx = [0] * K mask = 1 << i same |= M & mask for k in range(K): nx[k] = dp[k] for k in range(K-1): nx[k+1] += dp[k] if M & mask: nx[now] += 1 now += 1 for k in range(K): nx[k] %= P dp = nx dp[now] += 1 comb = [0] * (K * K) for n in range(K): for k in range(K): comb[n * K + k] = fact[n] * fact_inv[k] * fact_inv[n-k] % P def calc(k): dp = [0] * (k + 1) dp[0] = 1 for _ in range(N): nx = [0] * (k + 1) for i in range(k + 1): for j in range(k + 1 - i): nx[i + j] += dp[i] * comb[(k-i) * K + j] nx[i+j] %= P dp = nx return dp[-1] ans = 0 for k in range(K): ans += dp[k] * pow(N,k,P) ans %= P print(ans)