No.1931 Fraction 2
問題文最終更新日: 2022-04-29 23:10:44
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 342
(順位表)
の他の問題:
Problem Statement
You are given sequences of positive integers $A,B$ of length $N$. When $\displaystyle \sum_{i=1}^N \frac{A_i}{B_i}$ is expressed as an irreducible fraction $\dfrac{c}{d}$, find $c,d$ modulo $998244353$.
Constraints
- $1 \le N \le 2 \times 10^5$
- $1 \le A_i, B_i \le 2 \times 10^5$
- $\gcd(A_i,B_i)=1$
- All input values are integers
Input
$N$ $A_1$ $B_1$ $A_2$ $B_2$ $\vdots$ $A_N$ $B_N$
Output
Print $c,d$ as defined in the problem statement on $1$ line, separated by a space.
Sample
Sample 1
Input
2 1 2 2 3
Output
7 6
$\dfrac{1}{2}+\dfrac{2}{3}=\dfrac{7}{6}$.
Sample 2
Input
4 1 4 1 4 1 4 1 4
Output
1 1
Sample 3
Input
2 1 48 1 16
Output
1 12
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
ぷら