CF1924E.Paper Cutting Again
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a rectangular sheet of paper with initial height n and width m . Let the current height and width be h and w respectively. We introduce a xy -coordinate system so that the four corners of the sheet are (0,0),(w,0),(0,h) , and (w,h) . The sheet can then be cut along the lines x=1,2,…,w−1 and the lines y=1,2,…,h−1 . In each step, the paper is cut randomly along any one of these h+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 k . It can be shown that this answer can always be expressed as a fraction qp where p and q are coprime integers. Calculate p⋅q−1mod(109+7) .
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤57000 ). Description of the test cases follows.
The first line of each test case contains 3 integers n , m , and k ( 1≤n,m≤106 , 2≤k≤1012 ).
It is guaranteed that the sum of n and the sum of m over all test cases do not exceed 106 .
输出格式
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 10 so no cuts are required.
For the second test case, the area is exactly 8 so any one of the 4 possible cuts would make the area strictly less than 8 .
For the third test case, the final answer is 617=833333342mod(109+7) .
For the fourth test case, the final answer is 45=250000003mod(109+7) .