CF773F.Test Data Generation
NOI/NOI+/CTSC
通过率:0%
时间限制:5.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Test data generation is not an easy task! Often, generating big random test cases is not enough to ensure thorough testing of solutions for correctness.
For example, consider a problem from an old Codeforces round. Its input format looks roughly as follows:
The first line contains a single integer n (1 ≤ n ≤ max__n) — the size of the set. The second line contains n distinct integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ max__a) — the elements of the set in increasing order.
If you don't pay attention to the problem solution, it looks fairly easy to generate a good test case for this problem. Let n = max__n, take random distinct a__i from 1 to max__a, sort them... Soon you understand that it's not that easy.
Here is the actual problem solution. Let g be the greatest common divisor of _a_1, _a_2, ..., a__n. Let x = a__n / g - n. Then the correct solution outputs "Alice" if x is odd, and "Bob" if x is even.
Consider two wrong solutions to this problem which differ from the correct one only in the formula for calculating x.
The first wrong solution calculates x as x = a__n / g (without subtracting n).
The second wrong solution calculates x as x = a__n - n (without dividing by g).
A test case is interesting if it makes both wrong solutions output an incorrect answer.
Given max__n, max__a and q, find the number of interesting test cases satisfying the constraints, and output it modulo q.
测试数据生成并非易事!通常,仅生成大型随机测试用例不足以确保对解法正确性的充分测试。
例如,考虑某场旧 Codeforces 比赛中的一道题目。其输入格式大致如下:
第一行包含一个整数 n(1≤n≤max_n)——集合的大小。第二行包含 n 个互不相同的整数 a1,a2,…,an(1≤ai≤max_a)——按升序排列的集合元素。
若未仔细分析该题的正确解法,乍看之下为本题生成良好的测试用例似乎相当简单:令 n=max_n,从 1 到 max_a 中随机选取 n 个互不相同的 ai,再将其排序……但很快你便会意识到,事情远非如此简单。
该题的实际正确解法如下:令 g 为 a1,a2,…,an 的最大公约数;令 x=an/g−n。则正确解法输出 "Alice" 当且仅当 x 为奇数,输出 "Bob" 当且仅当 x 为偶数。
现考虑两个错误解法,它们仅在计算 x 的公式上与正确解法不同。
第一个错误解法将 x 计算为 x=an/g(未减去 n)。
第二个错误解法将 x 计算为 x=an−n(未除以 g)。
若一个测试用例使得上述两个错误解法均输出错误答案,则称其为有趣的测试用例。
给定 max_n、max_a 和 q,求满足约束条件的有趣测试用例的数量,并将结果对 q 取模后输出。
输入格式
The only line contains three integers max__n, max__a and q (1 ≤ max__n ≤ 30 000; max__n ≤ max__a ≤ 109; 104 ≤ q ≤ 105 + 129).
唯一一行包含三个整数 max_n、max_a 和 q(1 ≤ max_n ≤ 30000;max_n ≤ max_a ≤ 109;104 ≤ q ≤ 105 + 129)。
输出格式
Output a single integer — the number of test cases which satisfy the constraints and make both wrong solutions output an incorrect answer, modulo q.
输出一个整数——满足约束条件且使两种错误解法均输出错误答案的测试用例数量,对 $ q $ 取模。
输入输出样例
输入#1
3 6 100000
输出#1
4
输入#2
6 21 100129
输出#2
154
输入#3
58 787788 50216
输出#3
46009
说明/提示
In the first example, interesting test cases look as follows:
1 1 1 3
2 4 6 2 4 6
在第一个例子中,有趣的测试用例如下所示:
1 1 1 3
2 4 6 2 4 6
输入解题思路,AI测评打分。不知道怎么写?