Cod sursa(job #805975)

Utilizator Anele99Elena Robu Anele99 Data 1 noiembrie 2012 15:59:54
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.82 kb
#include<fstream>
using namespace std;
ifstream f("date.in");
ofstream g("date.out");
int zero(int n)
{
    int puterea=0,ck=n;
    while(10/ck>=1)
        {
            puterea=n/ck+puterea;
            ck=ck*n;
        }
    return ck;
}
int main()
{
    int p,l1,l2,pp,n,z,m;
    f>>p;
    l1=1;
    l2=1000000000;
    pp=0;
    while(l1<=l2 && pp==0){
        n=(l1+l2)/2;
        z=zero(n);
        if(z==p)
                    {
                        pp=1;
                        n=n-n%5;
                    }
            else if(z<p) l1=m+1;
            else l2=n-1;

    }
    if(pp==0) {
                g<<"-1";
                return 0;
              }
       else if(p==0) {
                g<<"1";
                return 0;
              }
          else {g<<n; return 0;}

}