CodeFoeces-742A

题目

原题链接:A. Arpa’s hard exam and Mehrdad’s naive cheat

题意

问1378的n次方的最后一位。投机取巧打开计算器,发现了规律。

代码

#include
using namespace std;
int main() {
    int n,s[4]={8,4,2,6};
    scanf("%d",&n);
    if(n==0){
        printf("1\n");
        return 0;
    }
    n=(n-1)%4;
    printf("%d\n",s[n]);
    return 0;
}

你可能感兴趣的:(CodeFoeces-742A)