A15460 | Function Sum
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Suppose you have an integer array $a_1, a_2, \dots, a_n$ .
Let $\operatorname{lsl}(i)$ be the number of indices $j$ ( $1 \le j < i$ ) such that $a_j < a_i$ .
Analogically, let $\operatorname{grr}(i)$ be the number of indices $j$ ( $i < j \le n$ ) such that $a_j > a_i$ .
Let's name position $i$ good in the array $a$ if $\operatorname{lsl}(i) < \operatorname{grr}(i)$ .
Finally, let's define a function $f$ on array $a$ $f(a)$ as the sum of all $a_i$ such that $i$ is good in $a$ .
Given two integers $n$ and $k$ , find the sum of $f(a)$ over all arrays $a$ of size $n$ such that $1 \leq a_i \leq k$ for all $1 \leq i \leq n$ modulo $998\,244\,353$ .
Let $\operatorname{lsl}(i)$ be the number of indices $j$ ( $1 \le j < i$ ) such that $a_j < a_i$ .
Analogically, let $\operatorname{grr}(i)$ be the number of indices $j$ ( $i < j \le n$ ) such that $a_j > a_i$ .
Let's name position $i$ good in the array $a$ if $\operatorname{lsl}(i) < \operatorname{grr}(i)$ .
Finally, let's define a function $f$ on array $a$ $f(a)$ as the sum of all $a_i$ such that $i$ is good in $a$ .
Given two integers $n$ and $k$ , find the sum of $f(a)$ over all arrays $a$ of size $n$ such that $1 \leq a_i \leq k$ for all $1 \leq i \leq n$ modulo $998\,244\,353$ .
输入格式
The first and only line contains two integers $n$ and $k$ ( $1 \leq n \leq 50$ ; $2 \leq k < 998\,244\,353$ ).
输出格式
Output a single integer — the sum of $f$ over all arrays $a$ of size $n$ modulo $998\,244\,353$ .
输入输出样例
输入 #1
3 3
输出 #1
28
输入 #2
5 6
输出 #2
34475
输入 #3
12 30
输出 #3
920711694
In the first test case:
$f([1,1,1]) = 0$ $f([2,2,3]) = 2 + 2 = 4$ $f([1,1,2]) = 1 + 1 = 2$ $f([2,3,1]) = 2$ $f([1,1,3]) = 1 + 1 = 2$ $f([2,3,2]) = 2$ $f([1,2,1]) = 1$ $f([2,3,3]) = 2$ $f([1,2,2]) = 1$ $f([3,1,1]) = 0$ $f([1,2,3]) = 1$ $f([3,1,2]) = 1$ $f([1,3,1]) = 1$ $f([3,1,3]) = 1$ $f([1,3,2]) = 1$ $f([3,2,1]) = 0$ $f([1,3,3]) = 1$ $f([3,2,2]) = 0$ $f([2,1,1]) = 0$ $f([3,2,3]) = 2$ $f([2,1,2]) = 1$ $f([3,3,1]) = 0$ $f([2,1,3]) = 2 + 1 = 3$ $f([3,3,2]) = 0$ $f([2,2,1]) = 0$ $f([3,3,3]) = 0$ $f([2,2,2]) = 0$ Adding up all of these values, we get $28$ as the answer.
$f([1,1,1]) = 0$ $f([2,2,3]) = 2 + 2 = 4$ $f([1,1,2]) = 1 + 1 = 2$ $f([2,3,1]) = 2$ $f([1,1,3]) = 1 + 1 = 2$ $f([2,3,2]) = 2$ $f([1,2,1]) = 1$ $f([2,3,3]) = 2$ $f([1,2,2]) = 1$ $f([3,1,1]) = 0$ $f([1,2,3]) = 1$ $f([3,1,2]) = 1$ $f([1,3,1]) = 1$ $f([3,1,3]) = 1$ $f([1,3,2]) = 1$ $f([3,2,1]) = 0$ $f([1,3,3]) = 1$ $f([3,2,2]) = 0$ $f([2,1,1]) = 0$ $f([3,2,3]) = 2$ $f([2,1,2]) = 1$ $f([3,3,1]) = 0$ $f([2,1,3]) = 2 + 1 = 3$ $f([3,3,2]) = 0$ $f([2,2,1]) = 0$ $f([3,3,3]) = 0$ $f([2,2,2]) = 0$ Adding up all of these values, we get $28$ as the answer.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted