VK Cup 2017 - Round 3
F
Test Data Generation
Codeforces
3400
原题
← E→
翻译中…

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*$.

翻译中…

Input

翻译中…

The only line contains three integers $*max*_{*n*}$, $*max*_{*a*}$ and $*q*$ ($1 ≤ *max*_{*n*} ≤ 30 000$; $*max*_{*n*} ≤ *max*_{*a*} ≤ 10^{9}$; $10^{4} ≤ *q* ≤ 10^{5} + 129$).

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

In the first example, interesting test cases look as follows:

翻译中…

1              1              1              3
2              4              6              2 4 6

翻译中…

样例

Input #1
3 6 100000
Output #1
4
InputCopy OutputCopy
Input #2
6 21 100129
Output #2
154
InputCopy OutputCopy
Input #3
58 787788 50216
Output #3
46009
InputCopy OutputCopy
题目信息
题号
773F
时间限制
5 s
内存限制
256 MB
标签
组合数学
分治
动态规划
FFT
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。