問題一覧 > 通常問題

No.864 Four Arithmetic Operations

レベル : / AI推定難易度 : 1175 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 236
作問者 : e869120 / テスター : tatyam
お気に入りにしたユーザー ProblemId : 3317 / 自分の提出
問題文最終更新日: 2019-08-16 21:14:42
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 220 (順位表) の他の問題:

Problem Statement

Output the number of integer tuples $(a, b, c, d)$ that satisfy the following conditions.

  • $a, b, c, d$ are all integers between $1$ and $N$, inclusive
  • $ab + bc + cd + da = K$

Constraints

All input data satisfy the following constraints.

  • $N$ is an integer between $1$ and $1 \ 000 \ 000 \ 000 \ 000$, inclusive
  • $K$ is an integer between $1$ and $1 \ 000 \ 000 \ 000 \ 000$, inclusive

Input

$N$
$K$

Output

Output the number of tuples $(a, b, c, d)$ that satisfy the conditions.
Print a newline at the end.

Sample

Sample 1
Input
3
6
Output
4

The $4$ combinations $(a, b, c, d) = (1, 1, 1, 2), (1, 1, 2, 1), (1, 2, 1, 1), (2, 1, 1, 1)$ satisfy the conditions.

Sample 2
Input
3
15
Output
8

The $8$ combinations $(a, b, c, d) = (1, 2, 2, 3), (1, 3, 2, 2), (2, 1, 3, 2), (2, 2, 1, 3), (2, 2, 3, 1), (2, 3, 1, 2), (3, 1, 2, 2), (3, 2, 2, 1)$ satisfy the conditions.

Sample 3
Input
16
189
Output
264

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。