Cod sursa(job #2554191)
Utilizator | Data | 22 februarie 2020 17:34:52 | |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.66 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int zeros(int n)
{
int ans=0;
while(n)
{
ans+=(n/5);
n/=5;
}
return ans;
}
int main()
{
int p,ok=1,n;
f>>p;
n=5*p;
if(p==0)
g<<1;
else
{
int aux,i;
for( i=5; i<=n; i+=5)
{
aux=zeros(i);
if(aux==p)
{
g<<i;
return 0;
}
if(aux>p)
{
g<<-1;
break;
}
}
}
return 0;
}