Cod sursa(job #793258)

Utilizator mihaitsMihai Zavoian mihaits Data 2 octombrie 2012 13:35:51
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <fstream>
#include <iostream>
using namespace std;

int p, i = 1, cinci, doi, m = 1, ic;

int main ( void )
{
	ifstream fin ( "fact.in" );
	ofstream fout ( "fact.out" );
	
	fin >> p;
	
	while ( m )
	{
		ic = i;
		while ( ic % 5 == 0 )
		{
			cinci ++;
			ic /= 5;
		}
		ic = i;
		while ( ic % 2 == 0 )
		{
			doi ++;
			ic /= 2;
		}
		if ( cinci >= doi )
			if ( doi >= p )
			{
				fout << i;
				m = 0;
			}
		if ( cinci < doi )
			if ( cinci >= p )
			{
				fout << i;
				m = 0;
			}
		i ++;
	}	
	fin.close();
	fout.close();
}