View Code of Problem 3696

#include <bits/stdc++.h>
using namespace std;
int a[10][4]={{0},{1},{6,2,4,8},{1,3,9,7},{6,4},
{5},{6},{1,7,9,3},{6,8,4,2},{1,9}};
int main(){
	int n;
	while(~scanf("%d",&n)){
		int t=n%10;
		if(t==0) printf("1\n");
		else if(t==1||t==5||t==6)
			printf("%d\n",a[t][0]);
		else if(t==2||t==3||t==7||t==8)
			printf("%d\n",a[t][n%4]);
		else 
			printf("%d\n",a[t][n%2]);	
	} 
}

Double click to view unformatted code.


Back to problem 3696