CF1832E.Combinatorics Problem

普及/提高-

通过率:0%

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 < y , then (xy)=0\binom{x}{y} = 0 ;
  • otherwise, (xy)=x!y!(xy)!\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)mod998244353b_1 = (\binom{1}{k} \cdot a_1) \bmod 998244353 ;
  • b2=((2k)a1+(1k)a2)mod998244353b_2 = (\binom{2}{k} \cdot a_1 + \binom{1}{k} \cdot a_2) \bmod 998244353 ;
  • b3=((3k)a1+(2k)a2+(1k)a3)mod998244353b_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(ij+1k)aj)mod998244353b_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.

输入格式

The only line of the input contains six integers nn , a1a_1 , xx , yy , mm and kk ( 1n1071 \le n \le 10^7 ; 0a1,x,y<m0 \le a_1, x, y < m ; 2m9982443532 \le m \le 998244353 ; 1k51 \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 2in2 \le i \le n , ai=(ai1x+y)modma_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=biic_i = b_i \cdot i (without taking modulo 998244353998244353 after the multiplication). Print the integer c1c2cnc_1 \oplus c_2 \oplus \dots \oplus c_n , where \oplus denotes the bitwise XOR operator.

输入输出样例

  • 输入#1

    5 8 2 3 100 2

    输出#1

    1283
首页