P27429 [AtCoder] Almost Pythagorean Triangles
提高
题目描述

Problem Description

Yoshio decided to call triangles with the following properties "Almost Pythagorean Triangles":

  • The lengths of the sides $ a, b, c $ are all natural numbers.
  • $ gcd(a, b, c) = 1 $
  • $a \leq b \leq c$
  • $ a^2 + b^2 + s^2 = c^2 $

However, Yoshio has no idea how many "Almost Pythagorean Triangles" exist.

Given the maximum perimeter $ L $ and $ s $, count the number of "Almost Pythagorean Triangles" on Yoshio's behalf.

Input Format

The input is given from the standard input in the following format:

$ L $ $ s $

  • An integer $ L $ ( $1 \leq L \leq 10^8$ ) representing the maximum perimeter of the triangle $ a + b + c $, and $ s $ ( $1 \leq s \leq 50$ ) are given separated by a space.

Output Format

Output the number of triangles that satisfy the conditions in one line.

Ensure a newline at the end of the output.

Sample Input and Output

Sample Input #1

30 1

Sample Output #1

2

Sample Input #2

50 7

Sample Output #2

1

Notes/Hints

Scoring

This problem has partial scoring.

  • If you correctly solve all test cases where $L \leq 10000$, you will be awarded 60 points.
  • If you correctly solve all test cases, you will be awarded an additional 140 points.

Sample Explanation 1

The triangles that satisfy the conditions are $ (2, 2, 3) $ and $ (4, 8, 9) $.

Sample Explanation 2

The only triangle that satisfies the conditions is $ (6, 6, 11) $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
30 1
样例输出
2