#G. [ABC315G] Ai + Bj + Ck = X (1 <= i, j, k <= N)

    Type: Default 2000ms 1024MiB

[ABC315G] Ai + Bj + Ck = X (1 <= i, j, k <= N)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

[ABC315G] Ai + Bj + Ck = X (1 <= i, j, k <= N)

题面翻译

给定 n,a,b,c,xn,a,b,c,x,求满足 1i,j,kn1 \le i,j,k \le nai+bj+ck=xai+bj+ck=x 的三元组 (i,j,k)(i,j,k) 的个数。1n1061 \le n \le 10^61a,b,c1091 \le a,b,c \le 10^91x3×10151 \le x \le 3 \times 10^{15}

题目描述

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

  • 1  i,j,k  N 1\ \le\ i,j,k\ \le\ N
  • Ai+Bj+Ck=X Ai+Bj+Ck=X

输入格式

输入格式如下:

N N A A B B C C X X

输出格式

输出一个非负整数表示答案。

样例 #1

样例输入 #1

5 3 1 5 15

样例输出 #1

3

样例 #2

样例输入 #2

1 1 1 1 1

样例输出 #2

0

样例 #3

样例输入 #3

100000 31415 92653 58979 1000000000

样例输出 #3

2896

提示

数据范围

  • 输入都是正整数
  • 1  N  106 1\ \le\ N\ \le\ 10^6
  • 1  A,B,C  109 1\ \le\ A,B,C\ \le\ 10^9
  • 1  X  3 × 1015 1\ \le\ X\ \le\ 3\ \times\ 10^{15}

样例解释1

满足条件的正整数有以下3组。- (1,2,2) (1,2,2) : $ 3\ \times\ 1\ +\ 1\ \times\ 2\ +\ 5\ \times\ 2\ =\ 15 $ - (2,4,1) (2,4,1) : $ 3\ \times\ 2\ +\ 1\ \times\ 4\ +\ 5\ \times\ 1\ =\ 15 $ - (3,1,1) (3,1,1) : $ 3\ \times\ 3\ +\ 1\ \times\ 1\ +\ 5\ \times\ 1\ =\ 15 $

9月19日周二晚上集训赛

Not Attended
Status
Done
Rule
IOI
Problem
8
Start at
2023-9-19 19:00
End at
2023-9-19 21:00
Duration
2 hour(s)
Host
Partic.
30