标签:des style color os io 2014 for line
快速幂<span style="color:#6633ff;">/******************************************************** author : Grant Yuan time : 2014.7.28 algorithm : 快速幂 *********************************************************/ #include <iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #define LL long long using namespace std; LL mod_pow(LL x) { LL res=1; LL n=x; while(n>0){ if(n&1) res=res*x%10; x=x*x%10; n>>=1; } return res%10; } int main() { int t;LL n,ans; scanf("%d",&t); while(t--){ scanf("%lld",&n); ans=mod_pow(n); printf("%lld\n",ans); } return 0; } </span>
标签:des style color os io 2014 for line
原文地址:http://blog.csdn.net/yuanchang_best/article/details/38229341