#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int T;
long n, k;
cin >> T;
for(int t = 0; t < T; t++)
{
int r = 0;
int r0 = 0;
cin >> n >> k;
for(int i = 0; i <= 9; i++)
{
r0 = r0 + pow(i,k);
}
r0 = r0 % 10;
long n1 = n / 10;
int n2 = n % 10;
r = n1 * r0;
for(int i = 1; i <= n2; i++)
{
r = (r + pow(i,k));
r = (int)abs(r % 10);
}
cout << abs(r%10) << endl;
}
return 0;
}
COJ 1347 Last Digit
最新推荐文章于 2024-10-27 05:04:08 发布