CF852F.Product transformation
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Consider an array A with N elements, all being the same integer a.
Define the product transformation as a simultaneous update A__i = A__i·A__i + 1, that is multiplying each element to the element right to it for
, with the last number A__N remaining the same. For example, if we start with an array A with a = 2 and N = 4, then after one product transformation A = [4, 4, 4, 2], and after two product transformations A = [16, 16, 8, 2].
Your simple task is to calculate the array A after M product transformations. Since the numbers can get quite big you should output them modulo Q.
考虑一个包含 N 个元素的数组 A,所有元素均为相同的整数 a。
定义乘积变换为一次同步更新:对每个 i=1,2,…,N−1,令 Ai=Ai⋅Ai+1,即每个元素除最后一个外均与其右侧相邻元素相乘;最后一个元素 AN 保持不变。例如,若初始数组 A 满足 a=2 且 N=4,则经过一次乘积变换后 A=[4, 4, 4, 2],再经过一次乘积变换后 A=[16, 16, 8, 2]。
你的简单任务是:计算经过 M 次乘积变换后的数组 A。由于数值可能非常大,请将结果对 Q 取模后输出。
输入格式
The first and only line of input contains four integers N, M, a, Q (7 ≤ Q ≤ 109 + 123, 2 ≤ a ≤ 106 + 123,
,
is prime), where
is the multiplicative order of the integer a modulo Q, see notes for definition.
输入仅有一行,包含四个整数 N、M、a、Q(其中 7 ≤ Q ≤ 109 + 123,2 ≤ a ≤ 106 + 123,
,
为质数),其中
表示整数 a 模 Q 的乘法阶(定义见注释)。
输出格式
You should output the array A from left to right.
你应该从左到右输出数组 A。
输入输出样例
输入#1
2 2 2 7
输出#1
1 2
说明/提示
The multiplicative order of a number a modulo Q
, is the smallest natural number x such that a__x mod Q = 1. For example,
.
数 a 对模 Q 的乘法阶(
)是指满足 axmodQ=1 的最小正整数 x。例如,
。
输入解题思路,AI测评打分。不知道怎么写?