B. Sum of Three Integers

    传统题 2000ms 256MiB

Sum of Three Integers

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem

You are given two integers KK and SS.
Three variable X,YX, Y and ZZ takes integer values satisfying 0X,Y,ZK0≤X,Y,Z≤K.
How many different assignments of values to X,YX, Y and ZZ are there such that X+Y+Z=SX + Y + Z = S?

Constraints

  • 2K25002≤K≤2500
  • 0S3K0≤S≤3K
  • KK and SS are integers.

Input

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

KK SS

Output

Print the number of the triples of X,YX, Y and ZZ that satisfy the condition.

Example : 1. in

2 2

Example : 1. out

6

There are six triples of X,YX, Y and ZZ that satisfy the condition:

  • X=0,Y=0,Z=2X = 0, Y = 0, Z = 2
  • X=0,Y=2,Z=0X = 0, Y = 2, Z = 0
  • X=2,Y=0,Z=0X = 2, Y = 0, Z = 0
  • X=0,Y=1,Z=1X = 0, Y = 1, Z = 1
  • X=1,Y=0,Z=1X = 1, Y = 0, Z = 1
  • X=1,Y=1,Z=0X = 1, Y = 1, Z = 0

Example : 2. in

5 15

Example : 2. out

1

The maximum value of X+Y+ZX + Y + Z is 1515, achieved by one triple of X,YX, Y and ZZ.

AtCoder-ABC051

未参加
状态
已结束
规则
ACM/ICPC
题目
4
开始于
2024-11-17 19:00
结束于
2024-11-17 21:00
持续时间
2 小时
主持人
参赛人数
4