Cod sursa(job #179885)

Utilizator Sabynutz236Sabau Sabin Nicolae Cristian Sabynutz236 Data 16 aprilie 2008 13:51:50
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
#include<stdio.h>
#include<limits.h>
int main()
{
	int i,n,f,p,j,nc=0,x=0;
	freopen("fact.in","r",stdin);
	freopen("fact.out","w",stdout);
	scanf("%d",&p);
	for(i=1;i<1000;i++)
	for(j=1,f=1;f<LONG_MAX;f*=j++)
	{
	while(f!>0)
	{
	nc++;
	f=f/10;
	}
	if(nc==p) {
	break;x=1;}
	}
	if(x!=0)
	printf("%d",j);
	else
	printf("%d",-1);
	return 0;
}