No.2269 The Last Digit of the Integer Part of eN!
Problem Statement
Consider the following problem:
An integer $N$ is given as input.
Find the last $1$ digit of $\lfloor e (N!) \rfloor$. (Hereafter, this value is called the answer to this problem.)
Here, $e$ is the base of the natural logarithm, and for a real number $x$, $\lfloor x \rfloor$ denotes the greatest integer not exceeding $x$.
A positive integer $T$ is given at the beginning of the input. Then answer $T$ such problems.
Input
The input is given from standard input in $1 + T$ lines in the following format:
- Line $1$ contains $T$.
- For each positive integer $t$ not exceeding $T$, line $1 + t$ contains the input $N$ for the $t$-th problem.
Constraints
The input satisfies the following constraints:
- $T$ is an integer satisfying $1 \leq T \leq 10^5$
- The input $N$ for each problem is an integer satisfying $0 \leq N \leq 10^{18}$
Output
For each positive integer $t$ not exceeding $T$, print the answer to the $t$-th problem on line $t$.
Print a newline at the end.
Sample
Sample 1
Input
1 1
Output
2
The greatest integer not exceeding $e (N!) = e = 2.718 \cdots$ is $2$, and its last $1$ digit is $2$.
Sample 2
Input
1 2
Output
5
The greatest integer not exceeding $e (N!) = 2e = 5.436 \cdots$ is $5$, and its last $1$ digit is $5$.
Sample 3
Input
2 4 3
Output
5 6
For the $1$-st problem, the input is $N = 4$. The greatest integer not exceeding $e (N!) = 24e = 65.238 \cdots$ is $65$, and its last $1$ digit is $5$.
For the $2$-nd problem, the input is $N = 3$. The greatest integer not exceeding $e (N!) = 6e = 16.309 \cdots$ is $16$, and its last $1$ digit is $6$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。