HRBUST

来源:互联网 发布:金蝶软件数据库安装 编辑:程序博客网 时间:2024/04/29 22:54

已知a和b,求出a^b的个位数。

Input

输入包含多组测试用例。

每组测试用例,包含两个数组a和b(0<a,b<=2^30)。

Output

对于每组测试用例,你需要输出a^b的个位数。

Sample Input
7 66 8 800
Sample Output

9 6

#include <iostream>#include <cstring>int man(){    int ans[10][5]={            { 0, 0, 0 ,0, 0},            { 1, 1, 1, 1, 1},            { 6, 2, 4, 8, 6},            { 1, 3, 9, 7, 1},            { 6, 4, 6, 4, 6},            { 5, 5, 5, 5, 5},            { 6, 6, 6, 6, 6},            { 1, 7, 9, 3, 1},            { 6, 8, 4, 2, 6},            { 1, 9, 1, 9, 1}    };    unsigned long a, b;    while (std::cin>>a>>b)    {        std::cout << ans[a%10][b%4] << std::endl;    }//std::cout << "Hello, World!" << std::endl;    return 0;}


0 0