Under construction

Still being built. Things may change

Sum of Counts

Time limit1sMemory limit1024 MB

Summary
Given n and m, find the sum of f(n, m, i) over i from 0 to n+m, where f counts pairs (x, y) with x+y=i in the box 0 to n by 0 to m.
Level

Easy1 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

For integers a,b,c≥0a, b, c \ge 0, let f(a,b,c)f(a, b, c) be the number of integer ordered pairs (x,y)(x, y) that satisfy 0≤x≤a0 \le x \le a, 0≤y≤b0 \le y \le b, and x+y=cx + y = c.

For example, the integer ordered pairs (x,y)(x, y) satisfying 0≤x≤20 \le x \le 2, 0≤y≤30 \le y \le 3, and x+y=3x + y = 3 are (0,3),(1,2),(2,1)(0, 3), (1, 2), (2, 1), three in total. So f(2,3,3)=3f(2, 3, 3) = 3.

Given positive integers n,mn, m, find

∑i=0n+mf(n,m,i)=f(n,m,0)+f(n,m,1)+⋯+f(n,m,n+m)\sum_{i=0}^{n+m} f(n, m, i) = f(n, m, 0) + f(n, m, 1) + \cdots + f(n, m, n+m)

For example, when n=2,m=1n = 2, m = 1, we have f(2,1,0)=1,f(2,1,1)=2,f(2,1,2)=2,f(2,1,3)=1f(2, 1, 0) = 1, f(2, 1, 1) = 2, f(2, 1, 2) = 2, f(2, 1, 3) = 1. Therefore the answer is 1+2+2+1=61 + 2 + 2 + 1 = 6.

Input

The first line contains positive integers n,mn, m separated by a space. (1≤n,m≤1001 \le n, m \le 100)

Output

Print the answer to the problem on the first line.

Examples3

  1. Example 1

    Input
    1 1
    
    Expected output
    4
    
  2. Example 2

    Input
    2 1
    
    Expected output
    6
    
  3. Example 3

    Input
    2 3
    
    Expected output
    12