Cod sursa(job #656619)

Utilizator Black_TigerSima Cristian Black_Tiger Data 4 ianuarie 2012 21:11:45
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<iostream>
#include<fstream>

using namespace std;

std::ifstream f("fact.in");
std::ofstream g("fact.out");
int main(void){
	
	
	long int	x=1,i=2,p,j;
	f>>p;
	if(p==0)
		g<<1;
	else if((p%2==1)&& (p!=1)) 
	g<<-1;
	else
	{
		
		
	bool go=true;
	while(go)
	{ 
		
		//imultim
		x=x*i;
		j=0;
		int x2=x;
		while(x2%10 == 0)
		{
			j++;
			x2=x2/10;
		}
	
		if(j==p)
			go=false;
	    else
			i++;
		
	}
g<<i;
	
	}
return 0;
}