Cod sursa(job #394725)

Utilizator toniobFMI - Barbalau Antonio toniob Data 11 februarie 2010 14:32:17
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <fstream>
using namespace std;

ifstream in ( "cifra.in" );
ofstream out ( "cifra.out" );

int T, N;

int patrat_10 ( int y )
{
	int de_returnat = 1;
	for ( int i = 1; i <= y; ++i )
		de_returnat = ( de_returnat * y ) %10;
	return de_returnat;
}

int calc ( int x )
{
	if ( x == 1 )
		return 1;
	return ( patrat_10 ( x ) + calc ( x - 1 ) ) % 10;
}

int main ()
{
	in >> T;
	for ( ; T; --T )
	{
		in >> N;
		out << calc ( N ) << "\n";
	}
	
	return 0;
}