| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 46 | 34 | 29 | 76.316% |
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