View Code of Problem 3696

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
    int a[10][4] = {
	{0,0,0,0},{1,1,1,1},{6,2,4,8},{1,3,9,7},{6,4,6,4},
	{5,5,5,5},{6,6,6,6},{1,7,9,3},{6,8,4,2},{1,9,1,9}};  
	int n;
	int b;
	while(scanf("%d",&n)!=EOF){
		if(n==0||n==1){
			cout<<"1"<<endl;
		}else{
			  b=a[n%10][(n-2)%4];
		}
		cout<<b<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3696