Cod sursa(job #905399)

Utilizator VladMSBonta vlad valentin VladMS Data 5 martie 2013 19:52:10
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <fstream>
#define pinf 1<<30
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long n,rez,nr,aux,i,nri;
int main()
{
    fin>>nr;
    if(nr==0)
        fout<<1<<'\n';
    else
        {
            n=100000005;
            while(rez>nr||rez==0)
            {
                n=n-5;
                aux=n;
                rez=0;
                nri=0;
                i=0;
                while(aux!=0)
                {
                    aux=aux/5;
                    rez+=aux;
                }

            }
            if(rez==nr)
            fout<<n<<'\n';
            else
            fout<<-1<<'\n';
        }
    return 0;

}