#P3336. [ZJOI2013] 话旧
[ZJOI2013] 话旧
Description
Kobayashi went with the Galaxy Team players to a space contest. Influenced by the experience, he became more academic. After returning, he found the world had changed a lot. Biyomon underwent ultimate evolution and became Phoenixmon; Mr. Jin published a paper, was promoted to professor, and joined the Galaxy Team selection committee.
One day, Kobayashi chatted with Professor Jin. The professor recalled the years when he studied circuit theory. He was once very interested in a certain triangular wave and explored it. Kobayashi grew curious, so Professor Jin formalized the topic.
There is a continuous function defined on , where is an integer, satisfying . All its extrema occur at integer points, and every local minimum of is . For any integer between and , on , is a linear function with slope or .
What Mr. Jin studies is: if he knows the function values at integer points, then:
- How many functions satisfy the conditions?
- Among all functions that satisfy the conditions, what is the largest possible value of ?
Kobayashi thought for a moment and came up with a good algorithm. What about you?
Input Format
The first line contains two integers separated by a space. The next lines each contain two integers, representing and .
Output Format
Output two integers in one line, corresponding to the answers to the two questions. Since the answer to the first question can be large, output it modulo .
2 0
1 1
6 9
4 2
4 2
2 0
4 2
6 0
5 1
2 0
0 0
0 0
1 2
Hint
- For 10% of the testdata, .
- For 20% of the testdata, .
- For 30% of the testdata, , .
- For 50% of the testdata, , .
- For 70% of the testdata, .
- Additionally, for 10% of the testdata, .
- For 100% of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号