Mai intai trebuie sa te autentifici.
Cod sursa(job #1975373)
Utilizator | Data | 30 aprilie 2017 17:25:08 | |
---|---|---|---|
Problema | Factorial | Scor | 35 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <fstream>
#include<iostream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long p,nr;
int n;
int exp(int n)
{
long long ok=0;
while(n%5==0){ok++;n=n/5;}
return ok;
}
int main()
{
fin>>p;
n=1;
nr=0;
if(nr==p)fout<<n;
else{n=0;
while(nr<p)
{
n+=5;
nr=nr+exp(n);
}
if(nr>p)fout<<-1;
else fout<<n;
}
return 0;
}