QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#847. ゲーム

Estadísticas

ご存知の通り、六花は数学が苦手です。そこで勇太は彼女にゲームを教えることにしました。最初に整数 $x$ が与えられます。各数には「スコア」 $f(x)$ があり、以下の手順でゲームが進行します。

  1. 自分のスコアに $f(x)$ を加算する。
  2. もし $x = 1$ ならば、ゲーム終了。
  3. そうでなければ、ランダムに素数 $p|x$ を選び、$x$ を $p$ で割る。その後、ステップ1に戻る。

スコアの期待値はいくらでしょうか?答えは $P = 10^9 + 7$ で割った余りを出力してください。

六花の計算能力を鍛えるため、勇太は彼女にできるだけ早く答えを出してほしいと考えています。また、問題が進むごとに勇太は $f$ の値を一つずつ変更します。もちろん、この問題は可愛い六花には難しすぎるため、あなたが彼女を助けてあげてください。

入力形式

1行目に2つの正整数 $x, t$ が与えられます。これは初期値と問題数(初期の $f$ も1問目とみなす)を表します。

続く1行には $d(x)$ 個の整数が与えられます($d(x)$ は $x$ の約数の個数)。$i$ 番目の数は、$x$ の約数を小さい順に並べたときの $i$ 番目の数 $v$ に対するスコア $f(v)$ です。

続く $t - 1$ 行には、それぞれ2つの数 $v, y$ が与えられます。これは $f(v)$ を $y$ に変更することを意味します。$v|x$ であることが保証されており、変更は永続的です。

出力形式

$t$ 行出力してください。各行は、その時点での問題(初期の $f$、および $t-1$ 回の変更後の $f$)に対する答えを表します。

入出力例

入力 1

6 1
1 2 4 8

出力 1

12

注記

1回目、六花は 6 を 2 または 3 で割ることができます。しかし、次は必ず 1 になるため、等確率で2つの過程をたどります:6 → 3 → 1 または 6 → 2 → 1。それぞれの過程のスコアは 13 と 11 なので、期待値は 12 となります。

サブタスク

すべてのデータにおいて、$1\le x \le 10^{12}, 1\le t \le 3 \times 10^5, 1\le f(v), y \le 10^9$ を満たします。

テストケース $x$ $t$ $x$ はある素数の $k$ 乗
$1 \sim 2$ $\leq 20$ $\leq 1$
$3 \sim 4$ $\leq 10^9$
$5 \sim 6$ $\leq 10^6$
$7 \sim 8$ $\leq 10^3$
$9$ $\leq 10^{12}$
$10$
$11$ $\leq 10^9$ $\leq 5\,000$
$12$ $\leq 10^{12}$ $\leq 10^4$
$13$ $\leq 10^9$ $\leq 5 \times 10^4$
$14$ $\leq 10^5$
$15$ $\leq 3\times 10^5$
$16$
$17$ $\leq 10^{12}$ $\leq 10^4$
$18$ $\leq 5 \times 10^4$
$19$ $\leq 10^5$
$20$ $\leq 3 \times 10^5$

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.