spoj#COUNTDIO. Linear Diophantine Equation
Linear Diophantine Equation
Given a positive integer M and N positive integers a1, a2, ..., aN. Count the number of non-negative integer tuples (x1, x2, ..., xN) such that:
a1 * x1 + a2 * x2 + ... + aN * xN = M
Input
- The first line contains two integers N and M.
- The second line contains N integers a1, a2, ..., aN respectively.
Output
- Output only one integer, the number of asked tuples modulo 998244353.
Constrains
- 1 ≤ N ≤ 60 000
- 1 ≤ M ≤ 1018
- 1 ≤ ai ≤ 60 000
- 1 ≤ a1 + a2 + ... + aN ≤ 60 000
Example
Input:
3 10 3 2 5
Output:
4
Input:
5 100000 1 3 4 6 1000
Output:
865762992
Note
- My solution runs in less than 0.8s for each input file, 6.3s in total.