Aizu - 0019 Factorial

题目:

Description

Write a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20.

Input

An integer n (1 ≤ n ≤ 20) in a line.

Output

Print the factorial of n in a line.

Sample Input

5

Output for the Sample Input

120

超级水题

话说这个OJ好像是日本的吧。

代码:

#include<iostream>
using namespace std;

long long fac[21] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800,87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000 };

int main()
{
	int n;
	cin >> n;
	cout << fac[n] << endl;
	return 0;
}

你可能感兴趣的:(Aizu - 0019 Factorial)