A13466 | Height All the Same
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Alice has got addicted to a game called Sirtet recently.
In Sirtet, player is given an $n \times m$ grid. Initially $a_{i,j}$ cubes are stacked up in the cell $(i,j)$ . Two cells are called adjacent if they share a side. Player can perform the following operations:
- stack up one cube in two adjacent cells;
- stack up two cubes in one cell.
Cubes mentioned above are identical in height.
Here is an illustration of the game. States on the right are obtained by performing one of the above operations on the state on the left, and grey cubes are added due to the operation.
Player's goal is to make the height of all cells the same (i.e. so that each cell has the same number of cubes in it) using above operations.
Alice, however, has found out that on some starting grids she may never reach the goal no matter what strategy she uses. Thus, she is wondering the number of initial grids such that
- $L \le a_{i,j} \le R$ for all $1 \le i \le n$ , $1 \le j \le m$ ;
- player can reach the goal using above operations.
Please help Alice with it. Notice that the answer might be large, please output the desired value modulo $998,244,353$ .
In Sirtet, player is given an $n \times m$ grid. Initially $a_{i,j}$ cubes are stacked up in the cell $(i,j)$ . Two cells are called adjacent if they share a side. Player can perform the following operations:
- stack up one cube in two adjacent cells;
- stack up two cubes in one cell.
Cubes mentioned above are identical in height.
Here is an illustration of the game. States on the right are obtained by performing one of the above operations on the state on the left, and grey cubes are added due to the operation.
Player's goal is to make the height of all cells the same (i.e. so that each cell has the same number of cubes in it) using above operations.
Alice, however, has found out that on some starting grids she may never reach the goal no matter what strategy she uses. Thus, she is wondering the number of initial grids such that
- $L \le a_{i,j} \le R$ for all $1 \le i \le n$ , $1 \le j \le m$ ;
- player can reach the goal using above operations.
Please help Alice with it. Notice that the answer might be large, please output the desired value modulo $998,244,353$ .
输入格式
The only line contains four integers $n$ , $m$ , $L$ and $R$ ( $1\le n,m,L,R \le 10^9$ , $L \le R$ , $n \cdot m \ge 2$ ).
输出格式
Output one integer, representing the desired answer modulo $998,244,353$ .
输入输出样例
输入 #1
2 2 1 1
输出 #1
1
输入 #2
1 2 1 2
输出 #2
2
In the first sample, the only initial grid that satisfies the requirements is $a_{1,1}=a_{2,1}=a_{1,2}=a_{2,2}=1$ . Thus the answer should be $1$ .
In the second sample, initial grids that satisfy the requirements are $a_{1,1}=a_{1,2}=1$ and $a_{1,1}=a_{1,2}=2$ . Thus the answer should be $2$ .
In the second sample, initial grids that satisfy the requirements are $a_{1,1}=a_{1,2}=1$ and $a_{1,1}=a_{1,2}=2$ . Thus the answer should be $2$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted