キーエンスプログラミングコンテスト2023夏(AtCoder Beginner Contest 315)
G
Ai + Bj + Ck = X (1 <= i, j, k <= N)
AtCoder
⌀ 2315
原题
← Ex→
翻译中…

Problem Statement

翻译中…

You are given integers $N,A,B,C,X$. Find the number of triples of integers $(i,j,k)$ that satisfy all of the following conditions.

翻译中…
  • $1 \le i,j,k \le N$
  • $Ai+Bj+Ck=X$
翻译中…

Constraints

翻译中…
  • All input values are integers.
  • $1 \le N \le 10^6$
  • $1 \le A,B,C \le 10^9$
  • $1 \le X \le 3 \times 10^{15}$
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N A B C X

翻译中…

Output

翻译中…

Print the answer as an integer.

翻译中…

样例

Input #1
5 3 1 5 15
Output #1
3
The following three triples satisfy the conditions. - $(1,2,2)$ : $3 \times 1 + 1 \times 2 + 5 \times 2 = 15$ - $(2,4,1)$ : $3 \times 2 + 1 \times 4 + 5 \times 1 = 15$ - $(3,1,1)$ : $3 \times 3 + 1 \times 1 + 5 \times 1 = 15$
Input #2
1 1 1 1 1
Output #2
0
Input #3
100000 31415 92653 58979 1000000000
Output #3
2896
题目信息

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。