#97. Binomial Convolution
Binomial Convolution
当前没有测试数据。
Description
Given two sequences and a positive integer . Calculate an integer sequence , satisfying:
$$c_k = \sum_{i=\max(k-m,0)}^{\min(k,n)} \binom k i a_i b_{k-i} \bmod M $$Here denotes the binomial coefficient.
Input Format
The first line consists of integer .
The second line consists of .
The third line consists of .
Output Format
Print one line, containing .
Example
2 5 114
5 1 4
1 9 1 9 8 10
5 46 27 42 100 108 84 42
The sequence is before modulo.
Limits
For of the test cases, it's guaranteed that .
For another , is a prime.
For another , is a power of .
For of the test cases, it's guaranteed that $0\le n, m\le 10^5, 2\le M\le 10^9, 0\le a_i, b_j < M$.