题号:NC237448
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld
题目描述
For any positive integer sequence

, define its weight
%3D%5Csum_%7Bi%3E1%7D%20%5Cgcd(a_i%2Ca_%7Bi-1%7D)%5Ccdot%20w(a_i))
。
Here
%3Dpx%5E3%2Bqx%5E2%2Brx)
.

are given constants。
Calculate the sum of the weight of all such sequences whose sum is

。
The answer might be very huge, print it module

.
输入描述:
The first line contains two integers
(
), denoting the sum and length of the sequence。
Second line contains three integers
(
).
输出描述:
Output one line containing the answer,
.