[2016-02-05][HDU][1097][A hard puzzle]
[2016-02-05][HDU][1097][A hard puzzle]
HDU - 1097
| Time Limit: 1000MS | Memory Limit: 32768KB | 64bit IO Format: %I64d & %I64u |
Description
lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^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 a^b's the last digit number.But everybody is too lazy to slove this problem,so they remit to you who is wise.
this puzzle describes that: gave a and b,how to know the a^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 should output the a^b's last digit number.
Sample Input
7 66 8 800
Sample Output
9 6
- 时间:2016-01-27 11:02:38 星期三
- 题目编号:
- 题目大意:
- 分析:
- 方法:
- 解题过程遇到问题:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | #include <vector>#include <list>#include <map>#include <set>#include <deque>#include <queue>#include <stack>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <cctype>#include <string>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <ctime>using namespace std;typedef long long LL;#define CLR(x,y) memset((x),(y),sizeof((x)))#define getint(x) int (x);scanf("%d",&(x))#define get2int(x,y) int (x),(y);scanf("%d%d",&(x),&(y))#define get3int(x,y,z) int (x),(y),(z);scanf("%d%d%d",&(x),&(y),&(z))#define getll(x) LL (x);scanf("%I64d",&(x))#define get2ll(x,y) LL (x),(y);scanf("%I64d%I64d",&(x),&(y))#define get3ll(x,y,z) LL (x),(y),(z);scanf("%I64d%I64d%I64d",&(x),&(y),&(z))#define getdb(x) double (x);scanf("%lf",&(x))#define get2db(x,y) double (x),(y);scanf("%lf%lf",&(x),&(y))#define get3db(x,y,z) double (x),(y),(z);scanf("%lf%lf%lf",&(x),&(y),&(z))#define getint2(x) scanf("%d",&(x))#define get2int2(x,y) scanf("%d%d",&(x),&(y))#define get3int2(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))#define getll2(x) scanf("%I64d",&(x))#define get2ll2(x,y) scanf("%I64d%I64d",&(x),&(y))#define get3ll2(x,y,z) scanf("%I64d%I64d%I64d",&(x),&(y),&(z))#define getdb2(x) scanf("%lf",&(x))#define get2db2(x,y) scanf("%lf%lf",&(x),&(y))#define get3db2(x,y,z) scanf("%lf%lf%lf",&(x),&(y),&(z))#define getstr(str) scanf("%s",str)#define get2str(str1,str2) scanf("%s",str1,str2)#define FOR(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define FORD(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)#define FOR2(x,y,z) for((x)=(y);(x)<(z);(x)++)#define FORD2(x,y,z) for((x)=(y);(x)>=(z);(x)--)const int maxn = 100;int res[maxn];int main(){ int a,b; while(~get2int2(a,b)) { if(b == 0) { printf("1\n"); continue; } a = a % 10; int t; res[0] = a; for(t = 1;t < maxn;t++) { res[t] = (res[t-1] * a)%10; if(res[t] == a) break; } printf("%d\n",res[ (b-1) % t ]); } return 0;} |
浙公网安备 33010602011771号