题目 - Rightmost Digit
Given a positive integer N, you should output the most right digit of N^N.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case contains a single positive integer N(1<=N<=1,000,000,000).
Output
For each test case, you should output the rightmost digit of N^N.
Sample Input
1 | 2 |
Sample Output
1 | 7 |
Hint
1 | In the first case, 3 * 3 * 3 = 27, so the rightmost digit is 7. |
题目大意:
求n的平方最右边的数字。
思路:
需要用到快速幂以及取模。
AC代码:
1 |
|