CF思维联系–CodeForces - 223 C Partial Sums(组合数学的先线性递推)
生活随笔
收集整理的這篇文章主要介紹了
CF思维联系–CodeForces - 223 C Partial Sums(组合数学的先线性递推)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
ACM思維題訓(xùn)練集合
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: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. 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 (ai?=?si). You task is to find array a after exactly k described operations are applied.Input
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 a1,?a2,?...,?an — elements of the array a (0?≤?ai?≤?109).Output
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.Examples
Input 3 1 1 2 3 Output 1 3 6 Input 5 0 3 14 15 92 6 Output 3 14 15 92 6如果把a(bǔ)1,a2,a3....an的系數(shù)取出,會(huì)有如下規(guī)律1,11,111,1111C00C10C20C301,21,321,4321,54321C11C21C31C411,31,631,10631C22C32C42C52如果把a(bǔ)1,a2,a3....an的系數(shù)取出,會(huì)有如下規(guī)律\\ 1 , 1 1,111,1111 \ C^0_0C^0_1C^0_2C^0_3\\ 1,21,321,4321,54321\ C^1_1C^1_2C^1_3C^1_4\\ 1,31,631,10\ 631\ C^2_2C^2_3 C^2_4C^2_5如果把a1,a2,a3....an的系數(shù)取出,會(huì)有如下規(guī)律1,11,111,1111?C00?C10?C20?C30?1,21,321,4321,54321?C11?C21?C31?C41?1,31,631,10?631?C22?C32?C42?C52?
這個(gè)題用lucas過(guò)不了,卡時(shí)間,然后寫遞推,感謝SHDL寫的遞推板子
總結(jié)
以上是生活随笔為你收集整理的CF思维联系–CodeForces - 223 C Partial Sums(组合数学的先线性递推)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: IOS设计模式浅析之桥接模式(Bridg
- 下一篇: 汽水音乐怎么复制歌曲链接