Follows 10162.c (Total 32 lines):

/* @JUDGE_ID:4461XX 10162 C "MATH" */
/* A */
/* detail in 10162.txt */
#include<stdio.h>
#include<string.h>

int main( void )
{
	char in[10000] ;
	int table[10][2]={ 0 , 7 , 1 , 8 , 5 , 4 , 2 , 7 , 8 , 3 ,
	                   3 , 8 , 9 , 4 , 2 , 1 , 8 , 5 , 7 , 4 } ;
	/*MakeTable*/
	int len , n , i ;

	while( scanf( "%s" , &in[1] )==1 ){
		if( !strcmp( &in[1] , "0" ) ) break ;

		in[0] = '0' ;
		len = strlen( &in[1] ) ;

		n = table[ in[len]-'0' ][ (in[len-1]-'0')%2 ] ;
		for( i=1 ; i<=(in[len-1]-'0')/2 ; ++i ){
			n += 4 ;
			n %= 10 ;
		}

		printf( "%d\n" , n ) ;
	}

	return 0 ;
}
/* @END_OF_SOURCE_CODE */

Back to statistics
Ya-Lin Huang (C)
huangyl@gmail.com