1004 N^n's lowest number

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.