B - Quadruple
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.
n的范围
Score : 400 points
Problem Statement
Given are integers N and K. How many quadruples of integers (a,b,c,d) satisfy both of the following conditions?
- 1≤a,b,c,d≤N
- a+b−c−d=K
Constraints
- 1≤N≤105
- −2(N−1)≤K≤2(N−1)
- All numbers in input are integers.
Input
Input is given from standard input in the following format:
N K
Output
Print the answer.
Sample Input 1
2 1
Sample Output 1
4
Four quadruples below satisfy the conditions:
- (a,b,c,d)=(2,1,1,1)
- (a,b,c,d)=(1,2,1,1)
- (a,b,c,d)=(2,2,2,1)
- (a,b,c,d)=(2,2,1,2)
Sample Input 2
2525 -425
Sample Output 2
10314607400
排位赛1
- Status
- Done
- Rule
- IOI
- Problem
- 8
- Start at
- 2023-7-11 8:00
- End at
- 2023-7-11 12:00
- Duration
- 4 hour(s)
- Host
- Partic.
- 21