QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 1024 MB 總分: 100

#2546. 高次幂

统计

给定整数 $s, t$ 和 $u$。 设 $a, b, c$ 为满足以下条件的三个不同的复数:

  • $a + b + c = s$
  • $ab + bc + ca = t$
  • $abc = u$

题目保证对于给定的 $s, t$ 和 $u$,这样的 $a, b, c$ 存在。 给定正整数 $n$ 和 $m$,计算以下比值:

$$\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)}$$

对 $998\,244\,353$ 取模。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 10^{18}$)。 第二行包含三个整数 $s, t$ 和 $u$ ($0 \le s, t, u < 998\,244\,353$)。 题目保证对于给定的 $s, t$ 和 $u$,题目描述中提到的三个不同的复数 $a, b, c$ 存在。

输出格式

可以证明答案可以表示为一个有理数 $p/q$,其中 $p$ 和 $q$ 为整数,$(p, q) = 1$,$q > 0$ 且 $q$ 不能被 $998\,244\,353$ 整除。 输出一个整数 $x$,满足 $0 \le x < 998\,244\,353$ 且 $qx - p$ 能被 $998\,244\,353$ 整除。

样例

样例输入 1

2 3
314 159 265

样例输出 1

159

样例输入 2

1000000000000000000 800000000000000000
6 11 6

样例输出 2

76083766

样例输入 3

1000000000000000000 500000000000000000
505459328 165146837 982639180

样例输出 3

228155372

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.