CF1924E.Paper Cutting Again

NOI/NOI+/CTSC

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a rectangular sheet of paper with initial height nn and width mm. Let the current height and width be hh and ww respectively. We introduce a xyxy-coordinate system so that the four corners of the sheet are (0,0),(w,0),(0,h)(0, 0), (w, 0), (0, h), and (w,h)(w, h). The sheet can then be cut along the lines x=1,2,…,w−1x = 1,2,\ldots,w-1 and the lines y=1,2,…,h−1y = 1,2,\ldots,h-1. In each step, the paper is cut randomly along any one of these h+w−2h+w-2 lines. After each vertical and horizontal cut, the right and bottom piece of paper respectively are discarded.

Find the expected number of steps required to make the area of the sheet of paper strictly less than kk. It can be shown that this answer can always be expressed as a fraction pq\dfrac{p}{q} where pp and qq are coprime integers. Calculate p⋅q−1 mod (109+7)p\cdot q^{-1} \bmod (10^9+7).

有一张初始高度为 nn、宽度为 mm 的矩形纸片。设当前高度和宽度分别为 hh 和 ww。我们引入一个 xyxy-坐标系,使得纸片的四个顶点坐标为 (0,0),(w,0),(0,h)(0, 0), (w, 0), (0, h) 和 (w,h)(w, h)。该纸片可沿直线 x=1,2,…,w−1x = 1,2,\ldots,w-1(竖直切割线)以及直线 y=1,2,…,h−1y = 1,2,\ldots,h-1(水平切割线)进行裁剪。每一步中,纸片在所有这些 h+w−2h+w-2 条切割线中随机选择一条进行裁剪;每次竖直裁剪后,右侧部分被丢弃;每次水平裁剪后,下侧部分被丢弃。

求使纸片面积严格小于 kk 所需步骤数的期望值。可以证明,该期望值恒可表示为最简分数 pq\dfrac{p}{q}(其中 pp 与 qq 互质)。请计算 p⋅q−1 mod (109+7)p\cdot q^{-1} \bmod (10^9+7)。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤570001 \le t \le 57000). Description of the test cases follows.

The first line of each test case contains 3 integers nn, mm, and kk (1≤n,m≤1061 \le n, m \le 10^6, 2≤k≤10122 \le k \le 10^{12}).

It is guaranteed that the sum of nn and the sum of mm over all test cases do not exceed 10610^6.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤570001 \le t \le 57000)。随后是各测试用例的描述。

每个测试用例的第一行包含三个整数 nn、mm 和 kk(1≤n,m≤1061 \le n, m \le 10^6,2≤k≤10122 \le k \le 10^{12})。

保证所有测试用例中 nn 的总和与 mm 的总和均不超过 10610^6。

输出格式

For each test case, print one integer — the answer to the problem.

对于每个测试用例,输出一个整数——即该问题的答案。

输入输出样例

  • 输入#1

    4
    2 4 10
    2 4 8
    2 4 2
    2 4 6

    输出#1

    0
    1
    833333342
    250000003

说明/提示

For the first test case, the area is already less than 1010 so no cuts are required.

For the second test case, the area is exactly 88 so any one of the 44 possible cuts would make the area strictly less than 88.

For the third test case, the final answer is 176=833 333 342 mod (109+7)\frac{17}{6} = 833\,333\,342\bmod (10^9+7).

For the fourth test case, the final answer is 54=250 000 003 mod (109+7)\frac{5}{4} = 250\,000\,003\bmod (10^9+7).

对于第一个测试用例,面积已经小于 1010,因此无需切割。

对于第二个测试用例,面积恰好为 88,因此任意一种 44 种可能的切割方式均能使面积严格小于 88。

对于第三个测试用例,最终答案为 176=833 333 342 mod (109+7)\frac{17}{6} = 833\,333\,342\bmod (10^9+7)。

对于第四个测试用例,最终答案为 54=250 000 003 mod (109+7)\frac{5}{4} = 250\,000\,003\bmod (10^9+7)。

输入解题思路,AI测评打分。不知道怎么写?

首页