QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 512 MB Total points: 100

#415. 王的象棋世界

統計

一个 $R\times C$ 的棋盘,你有 $Q$ 组询问,每次询问国王走 $R-1$ 步从 $(1,a)$ 到达 $(R,b)$ 有多少种方案。你只需要输出答案对 $998244353$ 取模的结果。

输入格式

第一行输入三个正整数 $R, C, Q$,表示棋盘的长宽以及询问次数。

接下来 $Q$ 行每行两个正整数 $a,b$,表示一组具体询问。

输出格式

输出 $Q$ 行每行一个整数,表示对应询问的方案数。

样例数据

样例 1 输入

13 10 10
10 1
2 2
9 1
10 5
8 8
9 1
9 3
7 5
5 6
8 10

样例 1 输出

328
45475
1142
12804
65715
1142
7995
58199
69552
29964

子任务

对于 $100\%$ 的数据,保证 $2\le C\le 10^5, C\le R\le 10^9, 1\le Q\le 10^5$。

子任务编号 $C\le$ $Q\le $ 分值
$1$ $10^2$ $10^4$ $11$
$2$ $10^3$ $10$ $14$
$3$ $10^5$ $25$
$4$ $10^5$ $10^2$ $30$
$5$ $10^5$ $20$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.