Multiplication Madness

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Nugget has failed his most recent math test on multiplication. To help him improve, Bruce has given Nugget N queries about multiplication. Each query comes in the form: x y, where x and y are non-negative integers. To solve the query, you must print out the product of all the integers between x and y (inclusive) modulo 10^9 + 7. Being a very lazy busy boy, Nugget asks you to build a program that can do this for him. As a reward, he offers you 7 points.

Note: If you are using Python 2/3, you should submit using PyPy 2/3 with fast I/O.

Input Specification

The first line will contain a positive integer N representing the number of queries.

The next N lines will contain non-negative integers x and y separated by a space.

Output Specification

On the i^\text{th} line, output the product of the integers between x and y modulo 10^9 + 7 of the i^\text{th} query.

Constraints

For all subtasks:

1 \le N \le 10^6

0 \le x \le y \le 10^6

Subtask 1 [15%]

1 \le N \le 10

Subtask 2 [85%]

No additional constraints.

Sample Input 1

4
1 4
2 4
3 4
4 4

Sample Output 1

24
24
12
4

Sample Input 2

3
10 999
17 1910
500000 505000

Sample Output 2

66208545
58404876
841914375

Comments


  • -1
    ColonelBy_team10  commented on July 29, 2021, 9:46 p.m.

    Is this solvable in Python/Java


    • 2
      DM__Oscar  commented on July 29, 2021, 10:47 p.m.

      Have you learned nothing about time complexities, Edwin?


      • 3
        ColonelBy_team10  commented on July 29, 2021, 11:15 p.m.

        😭😭 got doxxed on DMOJ


        • 5
          EZAF_ANDY  commented on Jan. 28, 2022, 8:41 p.m.

          mf named Edwin