View Code of Problem 3696

#include<bits/stdc++.h>
using namespace std;//3696
int a[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 n,m;
	while(scanf("%d",&n)!=EOF){
		if(n==0){
			printf("1\n");
		}
		else{
			m=n%10;
			if(m==0||m==1||m==5||m==6){
				printf("%d\n",a[m][0]);
			}
			else{
				printf("%d\n",a[m][(n-1)%4]);
			}
		}
	}			
	return 0;
}
	
	

Double click to view unformatted code.


Back to problem 3696