N的阶乘-加强版

N的阶乘-加强版

Tag:

Background

In class, gauss learned to compute the factorial of n and showed off to his younger brother von neumann when he got home. In order not to make Gauss too complacent, Von Neumann asked his brother a question: "Since you will seek the factorial of N, then you can help me calculate 1! +2!-3!+4!-5!+……N!” . Now Gaussian is baffled. Smart, can you help him?

课堂上高斯学会了用计算机求出NN的阶乘,回到家后就对弟弟冯诺依曼炫耀起来。
为了不让高斯太自满,冯诺依曼给哥哥出了个问题“既然你会求NN的阶乘,那么你帮我算算1!+2!3!+4!5!+N!1!+2!-3!+4!-5!+……N!”。这下可把高斯难住了,聪明的你能帮帮他吗?

Description

Fine out: 1!+2!-3!+4!-5!+……N!

1!+2!3!+4!5!+N!1!+2!-3!+4!-5!+……N!

Input

Enter an integer t (0 < t < = 20) in the first row to represent t groups of test data. The next line, a total of t positive integers n (0 < n < = 20).

第一行输入一个整数 T(0<T<=20)T(0<T<=20),代表有 TT 组测试数据。
之后 1行,共TT个正整数N(0<N<=20)N(0<N<=20)

Output

A total of T lines, one line and one integer, represent 1! +2! -3! +…..N! The value of.

共T行,一行一个整数,表示1!+2!3!+..N!1!+2!-3!+…..N!的值。

Input

2
2 4

Output

3
21

Limitation

T(0<T<=20)T(0<T<=20)
N(0<N<=20)N(0<N<=20)

Source

Amorphophallus Orz Group

信息

ID
1004
难度
3
分类
数学 点击显示
标签
递交数
2
已通过
2
通过率
100%
上传者

相关

在下列训练计划中:

AOG题库训练计划