Cod sursa(job #922329)

Utilizator alexandru70Ungurianu Alexandru alexandru70 Data 22 martie 2013 08:26:47
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <fstream>
using namespace std;

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

short pattArr[ 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 n,s;

int main()
{
	f >> n;
	for( int index = 1; index <= n; index++)
	{
		if( index % 4 != 0 )
		{
			s+= pattArr[ index % 10 ][index % 4 - 1];

		}
		else
		{
			s+= pattArr[ index % 10 ][3];
		}
		s%=10;
	}
	g << s;
	return 0;
}