1004 N^n's lowest number
Base time limit: 1 seconds Space limit: 131072 KB gives an integer n, the last digit of the decimal representation of the output n^n (n of N-th square). Input
A number n (1 <= n <= 10^9)
Output
The lowest digit of the output n^n
Input example
13
Output example
3
Follow the link;
#include <cstdio>intnum[Ten][4]={ 0,0,0,0, 1,0,0,0, 6,2,4,8, 1,3,9,7, 6,4,0,0, 5,0,0,0, 6,0,0,0, 1,7,9,3, 6,8,4,2, 1,9,0,0,};intMain () {intN; while(SCANF ("%d", &n)! =EOF) { intdig=n%Ten; intRec; Switch(Dig) { Case 0: Rec=0; Break; Case 1: Rec=1; Break; Case 2: Rec= num[dig][n%4]; Break; Case 3: Rec=num[dig][n%4]; Break; Case 4: Rec=num[dig][n%2]; Break; Case 5: Rec=5; Break; Case 6: Rec=6; Break; Case 7: Rec=num[dig][n%4]; Break; Case 8: Rec=num[dig][n%4]; Break; Case 9: Rec=num[dig][n%2]; Break; default: Break; } printf ("%d\n", REC); } return 0;}
1004 N^n's lowest number