Cod sursa(job #793225)

Utilizator mihaitsMihai Zavoian mihaits Data 2 octombrie 2012 12:52:00
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <fstream>
#include <iostream>
using namespace std;

int p, s = 1, i = 1, cs, j;

int main ( void )
{
	ifstream fin ( "fact.in" );
	ofstream fout ( "fact.out" );
	
	fin >> p;
	while ( i )
	{
		j = 0;
		s *= i;
		cout << s << '\n';
		cs = s;
		while ( cs % 10 == 0 )
		{
			j ++;
			cs /= 10;
		}
		if ( j >= p )
		{
			fout << i;
			break;
		}
		i ++;
	}
	
	fin.close();
	fout.close();
}