天天看点

HDOJ 1061 Rightmost Digit(循环问题)

Problem Description

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

2

3

4

Sample Output

7

6

HDOJ 1061 Rightmost Digit(循环问题)

题意:很简单,就是输出n^n的最后一个数字时什么。

思路:前面有过一个0-9的n次方的题目,HDOJ1097题,那一题中我用代码推出了循环节,这个题目,我用的循环节全为4了.

继续阅读