Cod sursa(job #557789)

Utilizator alyn_acalin alin alyn_ac Data 16 martie 2011 21:10:05
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include<fstream.h>
int functie(int c)
{
	int x=c;
	while(2)
	{
		if(x%5==0)
			{return x/5; break;}
		x--;
	}
}
int main()
{
	ifstream fin("fact.in");
	ofstream fout("fact.out");
	int i,p,a=0,b=1000000000,c,y;
	fin>>p;
	while(2)
	{
		c=(a+b)/2;
		y=functie(c);
		if(y<p) a=c+1;
		else
		if(y>p) b=c-1;
		else
		if(y==p)
			break;
	}
	if(p==0)
		fout<<1;
	else
		fout<<c;
	return 0;
}