HDU 1097

快速幂取模

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 #define LL long long
 5 LL a,b,c,d;
 6 int main()
 7 {
 8     while(~scanf("%lld%lld",&a,&b))
 9     {
10         c=1,d=a%10;
11         while(b)
12         {
13             if(b&1) c=(c*d)%10;
14             d=d*d%10;
15             b>>=1;
16         }
17         printf("%lld
",c);
18     }
19 }
我自倾杯,君且随意
原文地址:https://www.cnblogs.com/nicetomeetu/p/5451811.html