标签:string src def for ++ 题目 author panel upload
一个数N(1 <= N <= 10^9)
输出N^N的末位数字
13
3
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #define LL long long 6 using namespace std; 7 const LL MAXN=200000001; 8 inline LL read() 9 { 10 char c=getchar();LL flag=1,x=0; 11 while(c<‘0‘||c>‘9‘) {if(c==‘-‘) flag=-1;c=getchar();} 12 while(c>=‘0‘&&c<=‘9‘) x=(x*10+c-48),c=getchar(); return x*flag; 13 } 14 LL a[15]={1,1,4,4,2,1,1,4,4,2}; 15 LL n; 16 int main() 17 { 18 n=read(); 19 LL p=n%10; 20 n=n%a[p]; 21 if(n==0) 22 { 23 LL ans=1; 24 for(LL i=1;i<=a[p];i++) 25 ans=ans*p; 26 cout<<ans%10; 27 } 28 else 29 { 30 LL ans=1; 31 for(LL i=1;i<=n;i++) 32 ans=ans*p; 33 cout<<ans%10; 34 } 35 return 0; 36 }
标签:string src def for ++ 题目 author panel upload
原文地址:http://www.cnblogs.com/zwfymqz/p/7731963.html