CF1832E.Combinatorics Problem

提高+/省选-

通过率:0%

时间限制:4.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

Recall that the binomial coefficient (xy)\binom{x}{y} is calculated as follows (xx and yy are non-negative integers):

  • if x<yx \lt y, then (xy)=0\binom{x}{y} = 0;
  • otherwise, (xy)=x!y!⋅(x−y)!\binom{x}{y} = \frac{x!}{y! \cdot (x-y)!}.

You are given an array a1,a2,…,ana_1, a_2, \dots, a_n and an integer kk. You have to calculate a new array b1,b2,…,bnb_1, b_2, \dots, b_n, where

  • b1=((1k)⋅a1) mod 998244353b_1 = (\binom{1}{k} \cdot a_1) \bmod 998244353;
  • b2=((2k)⋅a1+(1k)⋅a2) mod 998244353b_2 = (\binom{2}{k} \cdot a_1 + \binom{1}{k} \cdot a_2) \bmod 998244353;
  • b3=((3k)⋅a1+(2k)⋅a2+(1k)⋅a3) mod 998244353b_3 = (\binom{3}{k} \cdot a_1 + \binom{2}{k} \cdot a_2 + \binom{1}{k} \cdot a_3) \bmod 998244353, and so on.

Formally, bi=(∑j=1i(i−j+1k)⋅aj) mod 998244353b_i = (\sum\limits_{j=1}^{i} \binom{i - j + 1}{k} \cdot a_j) \bmod 998244353.

Note that the array is given in a modified way, and you have to output it in a modified way as well.

回忆一下,二项式系数 (xy)\binom{x}{y} 的计算方式如下(其中 xx 和 yy 为非负整数):

  • 若 x<yx \lt y,则 (xy)=0\binom{x}{y} = 0;
  • 否则,(xy)=x!y!⋅(x−y)!\binom{x}{y} = \frac{x!}{y! \cdot (x-y)!}。

给定一个数组 a1,a2,…,ana_1, a_2, \dots, a_n 和一个整数 kk。你需要计算一个新数组 b1,b2,…,bnb_1, b_2, \dots, b_n,其中

  • b1=((1k)⋅a1) mod 998244353b_1 = (\binom{1}{k} \cdot a_1) \bmod 998244353;
  • b2=((2k)⋅a1+(1k)⋅a2) mod 998244353b_2 = (\binom{2}{k} \cdot a_1 + \binom{1}{k} \cdot a_2) \bmod 998244353;
  • b3=((3k)⋅a1+(2k)⋅a2+(1k)⋅a3) mod 998244353b_3 = (\binom{3}{k} \cdot a_1 + \binom{2}{k} \cdot a_2 + \binom{1}{k} \cdot a_3) \bmod 998244353,依此类推。

形式化地,bi=(∑j=1i(i−j+1k)⋅aj) mod 998244353b_i = \left(\sum\limits_{j=1}^{i} \binom{i - j + 1}{k} \cdot a_j\right) \bmod 998244353。

注意:输入数组以一种修改后的方式给出,且你输出的数组也需采用相同的修改方式。

输入格式

The only line of the input contains six integers nn, a1a_1, xx, yy, mm and kk (1≤n≤1071 \le n \le 10^7; 0≤a1,x,y<m0 \le a_1, x, y \lt m; 2≤m≤9982443532 \le m \le 998244353; 1≤k≤51 \le k \le 5).

The array [a1,a2,…,an][a_1, a_2, \dots, a_n] is generated as follows:

  • a1a_1 is given in the input;
  • for 2≤i≤n2 \le i \le n, ai=(ai−1⋅x+y) mod ma_i = (a_{i-1} \cdot x + y) \bmod m.

输入仅包含一行,其中有六个整数 nn、a1a_1、xx、yy、mm 和 kk(满足 1≤n≤1071 \le n \le 10^7;0≤a1,x,y<m0 \le a_1, x, y \lt m;2≤m≤9982443532 \le m \le 998244353;1≤k≤51 \le k \le 5)。

数组 [a1,a2,…,an][a_1, a_2, \dots, a_n] 按如下方式生成:

  • a1a_1 由输入给出;
  • 对于 2≤i≤n2 \le i \le n,有 ai=(ai−1⋅x+y) mod ma_i = (a_{i-1} \cdot x + y) \bmod m。

输出格式

Since outputting up to 10710^7 integers might be too slow, you have to do the following:

Let ci=bi⋅ic_i = b_i \cdot i (without taking modulo 998244353998244353 after the multiplication). Print the integer c1⊕c2⊕⋯⊕cnc_1 \oplus c_2 \oplus \dots \oplus c_n, where ⊕\oplus denotes the bitwise XOR operator.

由于输出最多 10710^7 个整数可能过于耗时,你需要执行以下操作:

令 ci=bi⋅ic_i = b_i \cdot i(乘法后不取模 998244353998244353)。输出整数 c1⊕c2⊕⋯⊕cnc_1 \oplus c_2 \oplus \dots \oplus c_n,其中 ⊕\oplus 表示按位异或运算符。

输入输出样例

  • 输入#1

    5 8 2 3 100 2

    输出#1

    1283

输入解题思路,AI测评打分。不知道怎么写?

首页