CF223C.Partial Sums

普及+/提高

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:

  1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 ≤ i ≤ n) of array s equals . The operation x mod y means that we take the remainder of the division of number x by number y.
  2. Then we write the contents of the array s to the array a. Element number i (1 ≤ i ≤ n) of the array s becomes the i-th element of the array a (a__i = s__i).

You task is to find array a after exactly k described operations are applied.

你有一个包含 $ n $ 个整数的数组 $ a $。数组元素的下标从 $ 1 $ 到 $ n $。我们定义如下两步操作:

  1. 首先,根据数组 $ a $ 构造一个由 $ n $ 个元素组成的前缀和数组 $ s $。数组 $ s $ 的第 $ i $ 个元素($ 1 \leq i \leq n $)等于
    。
    运算 $ x \bmod y $ 表示 $ x $ 除以 $ y $ 所得的余数。
  2. 然后,将数组 $ s $ 的内容写回数组 $ a $:即数组 $ s $ 的第 $ i $ 个元素成为数组 $ a $ 的第 $ i $ 个元素($ a_i = s_i $)。

你的任务是:求对数组 $ a $ 恰好执行 $ k $ 次上述操作后得到的数组 $ a $。

输入格式

The first line contains two space-separated integers n and k (1 ≤ n ≤ 2000, 0 ≤ k ≤ 109). The next line contains n space-separated integers _a_1, _a_2, ..., a__n — elements of the array a (0 ≤ a__i ≤ 109).

第一行包含两个以空格分隔的整数 nn 和 kk(1 ≤ n ≤ 20001 \leq n \leq 2000,0 ≤ k ≤ 1090 \leq k \leq 10^9)。
下一行包含 nn 个以空格分隔的整数 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n —— 数组 aa 的元素(0 ≤ ai ≤ 1090 \leq a_i \leq 10^9)。

输出格式

Print n integers — elements of the array a after the operations are applied to it. Print the elements in the order of increasing of their indexes in the array a. Separate the printed numbers by spaces.

输出对数组 aa 执行所有操作后得到的 nn 个整数——即数组 aa 的元素。按这些元素在数组 aa 中下标递增的顺序输出。各输出数字之间用空格分隔。

输入输出样例

  • 输入#1

    3 1
    1 2 3

    输出#1

    1 3 6
  • 输入#2

    5 0
    3 14 15 92 6

    输出#2

    3 14 15 92 6

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

首页