CF1747E.List Generation
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For given integers n and m , let's call a pair of arrays a and b of integers good, if they satisfy the following conditions:
- a and b have the same length, let their length be k .
- k≥2 and a1=0,ak=n,b1=0,bk=m .
- For each 1<i≤k the following holds: ai≥ai−1 , bi≥bi−1 , and ai+bi=ai−1+bi−1 .
Find the sum of ∣a∣ over all good pairs of arrays (a,b) . Since the answer can be very large, output it modulo 109+7 .
输入格式
The input consists of multiple test cases. The first line contains a single integer t(1≤t≤104) — the number of test cases. The description of the test cases follows.
The only line of each test case contains two integers n and m (1≤n,m≤5⋅106) .
It is guaranteed that the sum of n over all test cases does not exceed 5⋅106 and the sum of m over all test cases does not exceed 5⋅106 .
输出格式
For each test case, output a single integer — the sum of ∣a∣ over all good pairs of arrays (a,b) modulo 109+7 .
输入输出样例
输入#1
4 1 1 1 2 2 2 100 100
输出#1
8 26 101 886336572
说明/提示
In the first testcase, the good pairs of arrays are
- ([0,1],[0,1]) , length = 2 .
- ([0,1,1],[0,0,1]) , length = 3 .
- ([0,0,1],[0,1,1]) , length = 3 .
Hence the sum of the lengths would be 2+3+3=8 .