CF1626F.A Random Code Problem

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an integer array a0,a1,,an1a_0, a_1, \dots, a_{n - 1} , and an integer kk . You perform the following code with it:

<pre class="lstlisting">```
long long ans = 0; // create a 64-bit signed variable which is initially equal to 0<br></br>for(int i = 1; i <= k; i++)<br></br>{<br></br>  int idx = rnd.next(0, n - 1); // generate a random integer between 0 and n - 1, both inclusive<br></br>                                // each integer from 0 to n - 1 has the same probability of being chosen<br></br>  ans += a[idx];<br></br>  a[idx] -= (a[idx] % i);<br></br>}<br></br>

Your task is to calculate the expected value of the variable ans after performing this code.

Note that the input is generated according to special rules (see the input format section).

输入格式

The only line contains six integers nn , a0a_0 , xx , yy , kk and MM ( 1n1071 \le n \le 10^7 ; 1a0,x,y<M9982443531 \le a_0, x, y < M \le 998244353 ; 1k171 \le k \le 17 ).

The array aa in the input is constructed as follows:

  • a0a_0 is given in the input;
  • for every ii from 11 to n1n - 1 , the value of aia_i can be calculated as ai=(ai1x+y)modMa_i = (a_{i - 1} \cdot x + y) \bmod M .

输出格式

Let the expected value of the variable ans after performing the code be EE . It can be shown that EnkE \cdot n^k is an integer. You have to output this integer modulo 998244353998244353 .

输入输出样例

  • 输入#1

    3 10 3 5 13 88

    输出#1

    382842030
  • 输入#2

    2 15363 270880 34698 17 2357023

    输出#2

    319392398

说明/提示

The array in the first example test is [10,35,22][10, 35, 22] . In the second example, it is [15363,1418543][15363, 1418543] .

首页