Cod sursa(job #549227)

Utilizator RampageSergiu Caraian Rampage Data 8 martie 2011 11:34:10
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <fstream>
using namespace std;

ifstream f ("fact.in");
ofstream g ("fact.out");

int main()
    {
    float p,s=0;
    int j,a=0,b=200,x;
    bool flag=false;
    f>>p;
   
    while (flag!=true)
        {
        s=0;
        x=((a+b)/2);
	i=5;        
	
	do
            {
            j=i;
            while (j%5==0)
                {
                s++;
                j/=5;
                }
	i+=5;            
		}
		while (i<=x);
        if (s==p)
            flag=true;
        else
            if (s<p)
                a=x;
            if (s>p)
                b=x;
        }
    g<<x;
    g.close();
    return 0;
    }