思路:思路和1061是一样的(点击看1061题解)。
代码:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
#define mst(a,b) memset(a,b,sizeof(a))
#define eps 10e-8
const int MAX_ = 110;
const int MAX = 0x7fffffff;
int num[MAX_][6] = {{0},{1,1},
{4,2,4,8,6},
{4,3,9,7,1},
{2,4,6},
{1,5},
{1,6},
{4,7,9,3,1},
{4,8,4,2,6},
{2,9,1}
};
long long a,cnt,T, b;
double c, t, n;
int main(){
while(~scanf("%I64d%I64d",&a,&b)){
printf("%d\n",num[a%10][a%10?--b%num[a%10][0] + 1:0]);
}
return 0;
}