Rightmost Digit
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 40200 Accepted Submission (s): 15181
Problem Descriptiongiven A positive integer N, you should output the most right digit of n^n.
Inputthe input contains several test cases. The first line of the input was a single integer T which is the number of test cases. T test Cases follow.
Each test case is contains a single positive integer N (1<=n<=1,000,000,000).
Outputfor Each test case, you should output the rightmost digit of n^n.
Sample Input234
Sample Output76
HintIn the first case, 3 * 3 * 3 = digit, so the rightmost is 7.In the second case, 4 * 4 * 4 * 4 = at the first, so the rightmost D Igit is 6.
Authorignatius.l
Recommendwe has carefully selected several similar problems for you:1071 1170 1048 1032 10,621 There are regular questions, you can watch the rules first. Test instructions: Enter N to find the n^n digit. Attached code:
1#include <iostream>2 using namespacestd;3__int64 a[5];4 voidxxintT//by playing the table to find the law, found the n^n digit 4 a cycle, and only need to save single digit5 {6__int64 i,s=1;7t%=Ten;8 for(i=1; i<=4; i++)9 {Tens*=T; Onea[i]=s%Ten; A } - } - intMain () the { - intn,s,t; -Cin>>N; - while(n--) + { -Cin>>T; + xx (t); As=t%4; at if(s==0) -cout<<a[4]<<Endl; - Else -cout<<a[s]<<Endl; - } - return 0; in}
HDU 1061 rightmost Digit