1 solutions
-
0
C++ :
#include <iostream> #include <cmath> #include <algorithm> #include <cstdio> #include <cstring> using namespace std; int fun(int a,int b){ int ans=1; while(b){ if(b&1) b--,ans=(ans*a)%10; else b/=2,a=(a*a)%10; } return ans; } int solve(int n,int k){ k%=4; k+=4; if(n>10) return (((n/10)*solve(10,k))%10+solve(n%10,k))%10; int ans=0; for(int i=1;i<=n;i++) ans=(ans+fun(i,k))%10; return ans; } int main(){ int n,k; while(scanf("%d%d",&n,&k)!=EOF){ printf("%d\n",solve(n,k)); } return 0; }
- 1
Information
- ID
- 19602
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- (None)
- # Submissions
- 0
- Accepted
- 0
- Uploaded By