题目:https://www.nowcoder.com/practice/f54d8e6de61e4efb8cce3eebfd0e0daa?tpId=40&tqId=21355&tPage=2&rp=2&ru=/ta/kaoyan&qru=/ta/kaoyan/question-ranking
C++ 解法
#include <cstdio>typedef long long LL;int main(){LL n, table[1010];table[0] = 1;for(int i = 1; i <= 1000; i++){table[i] = table[i - 1] * i;}while(scanf("%lld", &n) != EOF){printf("%lld\n", table[n]);}}
JAVA解法
import java.math.BigInteger;import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);while (scanner.hasNext()){int n = scanner.nextInt();BigInteger i = new BigInteger("1");for (int j = 1; j <= n; j++) i=i.multiply(new BigInteger(String.valueOf(j)));System.out.println(i);}}}
