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(cin>>n){
		int t=n%10;
		if(t==1||t==5||t==6)
			cout<<a[t][0]<<endl;
		else if(t==2||t==3||t==7||t==8)
			cout<<a[t][n%4]<<endl;
		else if(t==4||t==9)
			cout<<a[t][n%2]<<endl;
		else
			cout<<0<<endl;
	} 
}

Double click to view unformatted code.


Back to problem 3696