Question:
A hard puzzle
Crawling in process...Crawling failedTime
Limit:1000 msMemory limit:32768kb
64bit Io format:% I64d & % i64u
Submitstatuspracticehdu
1097
Description
Lcy gives a hard puzzle to feng5166, LWG, jgshining And Ignatius: gave a and B, how to know the ^ B. everybody objects to this bt problem, so lcy makes the problem easier than begin.
This puzzle describes that: gave a and B, how to know the ^ B's the last digit number. but everybody is too lazy to slove this problem, so they remit to you who is wise.
Input
There are mutiple test cases. Each test cases consists of two numbers a and B (0 <a, B <= 2 ^ 30)
Output
For each test case, You shoshould output the ^ B's last digit number.
Sample Input
7 668 800
Sample output
96
This question! When everyone is stupid, it takes time for this question to be played today !!! Ah! Everything is possible !!!!
Train of Thought: Find the rule !!! As long as the last digit is obtained, it is only related to the last digit. The cycle of the ending number is 1, 5, and 6 is 1 (no matter how many power tails are the original number), the cycle of the ending number is 4, 9 is 2, and the cycle of the ending number is 2, 3, and 7, 8 is 4. to make the code simple, take the minimum public factor 4.
AC code:
#include<iostream>using namespace std;int main(){ int a[4],m,n; while(scanf("%d%d",&m,&n)!=EOF) { a[1]=m%10; a[2]=(a[1]*a[1])%10; a[3]=(a[1]*a[2])%10; a[0]=(a[1]*a[3])%10; n=n%4; printf("%d\n",a[n]); } return 0;}