3288 - Pascal's Triangle: Sum of Levels 3288 - Pascal's Triangle: Sum of Levels 3288 - Pascal's Triangle: Sum of Levels

Statistics Sub: 299 | AC: 120 | AC%: 40,13 | Score: 1,54
Created by 2015 UTP-COLOMBIA Internal Programming Contest VI - Hugo Humberto Morales Peña
Added by huhumope (2015-05-21)
Limits
Total Time: 3500 MS |Memory: 256 MB | Output: 64 MB | Size: 16 KB
Enabled languages
Available in

Description

From Wikipedia, the free encyclopedia : "In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. In much of the Western world it is named after French mathematician Blaise Pascal, although other mathematicians studied it centuries before him in India, Iran, China, Germany, and Italy".

Pascal's triangle is a triangle of integers, infinite and symmetrical, begins with a 1 in the first row (zero level triangle), and in the following rows are placed numbers in such way that each one is the sum of the two numbers it has above. It is assumed that the places outside the triangle contain zero, so that the edges of the triangle are formed by ones.

The following image contains the first levels of Pascal's triangle (from level 0 to level 6):
                  1
               1    1
            1    2    1
         1    3    3    1
      1    4    6    4    1
   1    5   10   10   5    1
1    6   15   20   15   6    1
...               ...                ...

In this problem you must compute the sum of all of Pascal's triangle's elements from level  m to level n.
From Wikipedia, the free encyclopedia : "In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. In much of the Western world it is named after French mathematician Blaise Pascal, although other mathematicians studied it centuries before him in India, Iran, China, Germany, and Italy".

Pascal's triangle is a triangle of integers, infinite and symmetrical, begins with a 1 in the first row (zero level triangle), and in the following rows are placed numbers in such way that each one is the sum of the two numbers it has above. It is assumed that the places outside the triangle contain zero, so that the edges of the triangle are formed by ones.

The following image contains the first levels of Pascal's triangle (from level 0 to level 6):
                  1
               1    1
            1    2    1
         1    3    3    1
      1    4    6    4    1
   1    5   10   10   5    1
1    6   15   20   15   6    1
...               ...                ...

In this problem you must compute the sum of all of Pascal's triangle's elements from level  m to level n.
From Wikipedia, the free encyclopedia : "In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. In much of the Western world it is named after French mathematician Blaise Pascal, although other mathematicians studied it centuries before him in India, Iran, China, Germany, and Italy".

Pascal's triangle is a triangle of integers, infinite and symmetrical, begins with a 1 in the first row (zero level triangle), and in the following rows are placed numbers in such way that each one is the sum of the two numbers it has above. It is assumed that the places outside the triangle contain zero, so that the edges of the triangle are formed by ones.

The following image contains the first levels of Pascal's triangle (from level 0 to level 6):
                  1
               1    1
            1    2    1
         1    3    3    1
      1    4    6    4    1
   1    5   10   10   5    1
1    6   15   20   15   6    1
...               ...                ...

In this problem you must compute the sum of all of Pascal's triangle's elements from level  m to level n.

Input specification

The input may contain several test cases (but no more than 510000). Each test case is presented on a single line, and contains two positive integers m and n (0 <= m <= n <= 1000). The input ends with m = - 1 and n = -1, and this case must not be processed.
The input may contain several test cases (but no more than 510000). Each test case is presented on a single line, and contains two positive integers m and n (0 <= m <= n <= 1000). The input ends with m = - 1 and n = -1, and this case must not be processed.
The input may contain several test cases (but no more than 510000). Each test case is presented on a single line, and contains two positive integers m and n (0 <= m <= n <= 1000). The input ends with m = - 1 and n = -1, and this case must not be processed.

Output specification

For each test case, your program must print the sum of all Pascal's triangle's elements from level m to level n mod 1000007. Each valid test case must generate just one output line.

mod operation means the remainder after division of one number by 1000007. Is denoted by the operator % in several programming languages.
For each test case, your program must print the sum of all Pascal's triangle's elements from level m to level n mod 1000007. Each valid test case must generate just one output line.

mod operation means the remainder after division of one number by 1000007. Is denoted by the operator % in several programming languages.
The input may contain several test cases (but no more than 510000). Each test case is presented on a single line, and contains two positive integers m and n (0 <= m <= n <= 1000). The input ends with m = - 1 and n = -1, and this case must not be processed.

Sample input

0 0
1 2
1 3
4 6
-1 -1

Sample output

1
6
14
112

Hint(s)

Use faster I/O methods
Use faster I/O methods
Use faster I/O methods

Recommendation

We have carefully selected several similar problems: 3378 | 3377 | 2916 | 3303 | 3361 | 2926