Banner Home Page DIY Contests Problems Ranklist Status Statistics

Factorial

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 38   Accepted Submission(s) : 7

Font: Times New Roman | Verdana | Georgia

Font Size: ¡û ¡ú

Problem Description

In mathematics, the factorial of a non-negative integer n, denoted by n!,
is the product of all positive integers less than or equal to n. For example,
5! = 5 X 4 X 3 X 2 X 1 = 120.
The value of 0! is 1
The factorial operation is encountered in many areas of mathematics.
In this problem you are given two numbers m and n, you have to compute the
sum of m! and n! .

Input

Input consists of several lines of integer numbers. The first line contains an integer t(less than 1000),
which is the number of cases to be tested, followed by t lines, two integers m and n (1<=m,n<=250)
on each line.

Output

The output contains the sum of m! and n! .

Sample Input

2
1 1
2 3

Sample Output

2
8

Author

MummyDing

Statistic | Submit | Back