#P10383. 「HOI R1」杂分选约
「HOI R1」杂分选约
Background
Please note the unusual time limit of this problem.
Because Python comes with built-in high-precision multiplication and runs fairly fast, brute-force programs written in Python can pass most test points under normal time limits. Therefore, the time limit for this problem is set to .
Mr. Huang is a math teacher who is very good at calculations and is famous for "Huang-style reduction." Now he asked little to solve this problem. But little seems not very capable, so he asks you for help.
Problem Description
Represent
$$\dfrac{\displaystyle\prod_{i=1}^n a_i}{\displaystyle\prod_{j=1}^m b_j}$$as a lowest-term fraction , and output and .
A kind classmate also gave little an integer , which is the Subtask that the test point belongs to.
Input Format
The first line contains three integers , , and .
The second line contains integers .
The third line contains integers .
Output Format
Output two numbers and in the first line.
6 8 0
540000 350000 110000 130000 170000 970000
2000 5000 1000 1000 97000 17000 143000 210000
9 10
Hint
Notes
:Baidu Baike:A lowest-term fraction is a fraction whose numerator and denominator have only the common factor . In other words, the numerator and denominator are coprime. It is also called a reduced fraction. For example: one half, two thirds, nine eighths, three eighths, and so on.
Sample Explanation
$\dfrac{540000\times350000\times110000\times130000\times170000\times970000}{2000\times5000\times1000\times1000\times97000\times17000\times143000\times210000}=\dfrac{9}{10}$, .
Constraints and Agreements
This problem uses bundled tests.
| Subtask | Score | Constraints |
|---|---|---|
| #0 | 0 | Same as the sample |
| #1 | , , | |
| #2 | , , | |
| #3 | , , | |
| #4 | , , | |
| #5 | , , , | |
| #6 | , , , | |
| #7 | , , | |
| #8 | , , | |
| #9 | , , |
Tips
Nobody writes high precision.
The time limit is small and the input size is large. If you believe your algorithm has the right complexity, try optimizing your I/O speed.
Translated by ChatGPT 5