CF1626F.A Random Code Problem
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an integer array a0,a1,…,an−1, and an integer k. You perform the following code with it:
long long ans = 0; // create a 64-bit signed variable which is initially equal to 0for(int i = 1; i <= k; i++){ int idx = rnd.next(0, n - 1); // generate a random integer between 0 and n - 1, both inclusive // each integer from 0 to n - 1 has the same probability of being chosen ans += a[idx]; a[idx] -= (a[idx] % i);}
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).
给你一个整数数组 a0,a1,…,an−1 和一个整数 k。你将对它执行以下代码:
long long ans = 0; // 创建一个初始值为 0 的 64 位有符号变量
for(int i = 1; i <= k; i++){
int idx = rnd.next(0, n - 1); // 在区间 $[0, n - 1]$ 内生成一个随机整数(含端点)
// 区间内每个整数被选中的概率均等
ans += a[idx];
a[idx] -= (a[idx] % i);
}
你的任务是计算执行完该代码后变量 ans 的期望值。
注意:输入数据是根据特殊规则生成的(参见“输入格式”部分)。
输入格式
The only line contains six integers n, a0, x, y, k and M (1≤n≤107; 1≤a0,x,y<M≤998244353; 1≤k≤17).
The array a in the input is constructed as follows:
- a0 is given in the input;
- for every i from 1 to n−1, the value of ai can be calculated as ai=(ai−1⋅x+y)modM.
唯一一行包含六个整数 n、a0、x、y、k 和 M(1≤n≤107;1≤a0,x,y<M≤998244353;1≤k≤17)。
输入中的数组 a 按如下方式构造:
- a0 由输入给出;
- 对每个从 1 到 n−1 的 i,ai 的值按公式 ai=(ai−1⋅x+y)modM 计算。
输出格式
Let the expected value of the variable ans after performing the code be E. It can be shown that E⋅nk is an integer. You have to output this integer modulo 998244353.
令执行代码后变量 ans 的期望值为 E。可以证明 E⋅nk 是一个整数。你需要输出该整数对 998244353 取模的结果。
输入输出样例
输入#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]. In the second example, it is [15363,1418543].
第一个示例测试中的数组为 [10,35,22]。第二个示例中的数组为 [15363,1418543]。
输入解题思路,AI测评打分。不知道怎么写?