CF2211B.Mickey Mouse Constructive
普及-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Given an array $ a $ , let $ f(a) $ be the number of ways to partition $ a $ into one or more subarrays $ ^{\text{∗}} $ such that:
- Each element appears in exactly one subarray.
- All subarrays have the same sum.
For example, if $ a=[1,1] $ , then $ f(a)=2 $ , because there are two such ways to partition $ [1,1] $ :
- $ [1,1] $ , where the only subarray has sum $ 2 $ .
- $ [1]+[1] $ , where both subarrays have sum $ 1 $ .
You are given two integers $ x $ and $ y $ . Find the minimum value of $ f(a) $ over all arrays $ a $ of length $ x+y $ , consisting of $ x $ copies of the number $ 1 $ , and $ y $ copies of the number $ -1 $ in some order. Since this answer may be large, output the answer modulo $ 676,767,677 $ . Additionally, you should construct one array that achieves this minimal value.
$ ^{\text{∗}} $ An array $ b $ is a subarray of an array $ c $ if $ b $ can be obtained from $ c $ by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 10^4 $ ). The description of the test cases follows.
The first line of each test case contains two integers $ x $ and $ y $ ( $ 0 \leq x,y \leq 2\cdot 10^5 $ ). It is guaranteed that $ x+y \geq 1 $ .
It is guaranteed that the sum of $ x $ over all test cases does not exceed $ 2\cdot 10^5 $ , and the sum of $ y $ over all test cases does not exceed $ 2\cdot 10^5 $ .
输出格式
For each test case, output two lines: the minimum value of $ f(a) $ over all valid arrays $ a $ modulo $ 676,767,677 $ , and an example of an array that achieves the minimal result. Note you are minimizing $ f(a) $ , and taking that minimum value modulo $ 676,767,677 $ , not finding the minimal possible result of $ f(a) $ mod $ 676,767,677 $ .
输入输出样例
输入#1
4 2 0 1 1 6 7 1 3
输出#1
2 1 1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 2 -1 -1 -1 1
说明/提示
In the first test case, $ x=2 $ and $ y=0 $ . The only possible array is $ a=[1,1] $ , with $ f(a)=2 $ as explained above.
In the second case, $ x=1 $ and $ y=1 $ . One possible array that minimizes $ f(a) $ is $ a=[1,-1] $ , where $ f(a)=1 $ (as the only way to partition into subarrays with all subarrays having equal sum is $ [[1,-1]] $ ).
输入解题思路,AI测评打分。不知道怎么写?