CF1332E.Height All the Same
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Alice has got addicted to a game called Sirtet recently.
In Sirtet, player is given an n×m grid. Initially ai,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≤ai,j≤R for all 1≤i≤n , 1≤j≤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≤n,m,L,R≤109 , L≤R , n⋅m≥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 a1,1=a2,1=a1,2=a2,2=1 . Thus the answer should be 1 .
In the second sample, initial grids that satisfy the requirements are a1,1=a1,2=1 and a1,1=a1,2=2 . Thus the answer should be 2 .