// http://www.spoj.com/problems/LASTDIG/
#include <iostream>
using namespace std;
int dat[10][4]={{0,0,0,0},
{1,1,1,1},
{2,4,8,6},
{3,9,7,1},
{4,6,4,6},
{5,5,5,5},
{6,6,6,6},
{7,9,3,1},
{8,4,2,6},
{9,1,9,1}};
int main(int argc, char* argv[]) {
int t;
cin >> t;
while (t-- >0) {
long long a,b;
cin >> a >> b;
if (b==0) cout << 1 << endl;
else
cout << dat[a%10][(b-1)%4] << endl;
}
}
The last digit
最新推荐文章于 2022-12-26 19:23:38 发布