QOJ.ac

QOJ

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

#4285. 帕特里克的三角形

Statistics

Patrick 是一位不知名的数学家,他渴望成名。Patrick 听说数学家 Blaise Pascal 因为他的三角形——帕斯卡三角形(Pascal’s triangle)而闻名于世。

$$ \begin{array}{ccccccccc} & & & & 1 & & & & \\ & & & 1 & & 1 & & & \\ & & 1 & & 2 & & 1 & & \\ & 1 & & 3 & & 3 & & 1 & \\ 1 & & 4 & & 6 & & 4 & & 1 \end{array} $$

Patrick 认为,如果他能构思出属于自己的三角形——Patrick 三角形,那么他或许也能成名。在经过长时间的思考后,他提出了以下构造方法:

  1. 在三角形的左侧和右侧边缘放置三角数 $1, 3, 6, 10, 15, 21, \dots$。

$$ \begin{array}{ccccccc} & & & 1 & & & \\ & & 3 & & 3 & & \\ & 6 & & & & 6 & \\ 10 & & & & & & 10 \\ 15 & & & & & & 15 \end{array} $$

  1. 填充三角形内部,将左上方和右上方两个数相加,构造方式与帕斯卡三角形相同。

$$ \begin{array}{ccccccccc} & & & & 1 & & & & \\ & & & 3 & & 3 & & & \\ & & 6 & & 6 & & 6 & & \\ & 10 & & 12 & & 12 & & 10 & \\ 15 & & 22 & & 24 & & 22 & & 15 \end{array} $$

Patrick 知道,要让他的三角形使他成名,他必须确保此前没有人发明过它。于是他在在线整数数列大全(OEIS.org)上进行了搜索,幸运的是,OEIS 中并没有收录他的三角形。

现在只剩下一件事了:将他的三角形上传到 OEIS 并成名。为此,Patrick 手工计算了该三角形的前 $10^6$ 行。但在上传之前,他想确保自己的计算没有错误。你能帮他检查一下计算结果吗?

前 6 个三角数。图片来源:Wikimedia Commons, CC BY-SA 3.0。

输入格式

第一行包含一个整数 $Q$ ($1 \le Q \le 2 \cdot 10^5$),表示查询的数量。接下来的 $Q$ 行,每行包含三个空格分隔的整数 $N, K, X$ ($1 \le K \le N \le 10^6, 0 \le X < 10^9 + 7$),其中 $X$ 是 Patrick 计算出的 Patrick 三角形第 $N$ 行第 $K$ 个数对 $10^9 + 7$ 取模后的值。Patrick 想知道 $X$ 是否正确。

输出格式

对于每个查询,如果 Patrick 三角形第 $N$ 行第 $K$ 个数对 $10^9 + 7$ 取模的结果等于 $X$,则输出一行字符串 Correct,否则输出 Incorrect

样例

输入 1

5
4 1 10
4 4 15
3 2 6
6 2 37
123456 61728 664742090

输出 1

Correct
Incorrect
Correct
Correct
Correct

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.