Cod sursa(job #1366480)

Utilizator Radu_FilipescuFilipescu Radu Radu_Filipescu Data 1 martie 2015 09:16:41
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>

using namespace std;

ifstream fin("fact.in");
ofstream fout("fact.out");

int main()
{
    long long ok,put=0,aux,p,i;

    fin>>p;
    fin.close();

    aux=p;
    while (aux>=5) if(aux%5==0) {put++; aux=aux/5;}
                   else aux=aux-aux%5;
   // fout<<put;

aux=1;
for(i=1; i<=put; i++) aux=aux*5;

if (aux==p) fout<<-1;
else if(p==0) fout<<1;
     else fout<<(p-put)*5;

fout.close();
    return 0;
}