CF773F.Test Data Generation

普及/提高-

通过率:0%

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 nn ( 1<=n<=maxn1<=n<=max_{n} ) — the size of the set. The second line contains nn distinct integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=maxa1<=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=maxnn=max_{n} , take random distinct aia_{i} from 1 to maxamax_{a} , sort them... Soon you understand that it's not that easy.

Here is the actual problem solution. Let gg be the greatest common divisor of a1,a2,...,ana_{1},a_{2},...,a_{n} . Let x=an/gnx=a_{n}/g-n . Then the correct solution outputs "Alice" if xx is odd, and "Bob" if xx is even.

Consider two wrong solutions to this problem which differ from the correct one only in the formula for calculating xx .

The first wrong solution calculates xx as x=an/gx=a_{n}/g (without subtracting nn ).

The second wrong solution calculates xx as x=annx=a_{n}-n (without dividing by gg ).

A test case is interesting if it makes both wrong solutions output an incorrect answer.

Given maxnmax_{n} , maxamax_{a} and qq , find the number of interesting test cases satisfying the constraints, and output it modulo qq .

输入格式

The only line contains three integers maxnmax_{n} , maxamax_{a} and qq ( 1<=maxn<=300001<=max_{n}<=30000 ; maxn<=maxa<=109max_{n}<=max_{a}<=10^{9} ; 104<=q<=105+12910^{4}<=q<=10^{5}+129 ).

输出格式

Output a single integer — the number of test cases which satisfy the constraints and make both wrong solutions output an incorrect answer, modulo qq .

输入输出样例

  • 输入#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:

<br></br>1 1 1 3<br></br>2 4 6 2 4 6<br></br>

首页