시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 1024 MB | 23 | 16 | 15 | 71.429% |
Given are integers $s$, $t$, and $u$.
Let $a$, $b$, and $c$ be distinct complex numbers that satisfy the following conditions:
It is guaranteed that such $a$, $b$, and $c$ exist for the given $s$, $t$, and $u$.
Given positive integers $n$ and $m$, calculate the ratio
$$ \frac{a^n(b^m-c^m)+b^n(c^m-a^m)+c^n(a^m-b^m)}{(a-b)(b-c)(c-a)} $$
modulo $998\,244\,353$.
The first line of input contains two integers $n$ and $m$ ($1 \le n, m \le 10^{18}$).
The second line contains three integers $s$, $t$ and $u$ ($0 \le s, t, u < 998\,244\,353$).
It is guaranteed that the distinct complex numbers $a$, $b$, and $c$ from the statement exist for the given $s$, $t$, and $u$.
It can be shown that the answer can be represented as a rational number $p/q$ where $p$ and $q$ are integers, $(p,q)=1$, $q>0$ and $q$ is not divisible by $998\,244\,353$.
2 3 314 159 265
159
1000000000000000000 800000000000000000 6 11 6
76083766
1000000000000000000 500000000000000000 505459328 165146837 982639180
228155372